Python - access network
来源:互联网 发布:java窗口程序实例 编辑:程序博客网 时间:2024/06/11 12:48
TCP Network
Transport Control Protocol(TCP) is built on top of IP.
TCP assumes IP might lose some data, so tcp will stores and retransmits data if it seems to be lost(when receive duplicate ACKs or ACK is time-out)
TCP will handle “flow control” using a transmit window (wnd)
TCP Connection / Sockets: network socket is an endpoint of a bidirectional inter-process communication flow.
TCP Port Number: a port is an application-specific software communications endpoint. It allows multiple networked applications to coexist on the same server.
Sockets in Python
Python has built-in support for tcp sockets
import socket
import socketmysock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)# connect('host', 'port number')mysock.connect( ('www.py4inf.com', 80) )# send our request, ask for some webpagemysock.send('GET http://www.py4inf.com/code/romeo.txt HTTP/1.0\n\n')# receive datawhile True: data = mysock.recv(512) if ( len(data) < 1 ) : break print data# don't forget to close the socketmysock.close()
we can make HTTP easier with urllib
using urllib model
urllib can do all the sockets work for us and make web pages look like a file. In a word, it is more convenient.
Note: there are some differences between python2 and python3 when using urllib. Here, I use python3 as standard.
- Python - access network
- Access Network
- [Computer and Network Security] Gaining Access using Network Attacks
- RH253 Unit 3 Network Resource Access Control
- could not access network location \Hewlett-Packard\\
- Optimizing Downloads for Efficient Network Access
- CM Config File-Network Access Control Object.
- Selenium Network error 或 Access Denied 错误
- RDO Stack:VMs cannot access external network.
- use Network Service account to access DB
- Python & Deep Belief Network
- python network programming tutorial
- python network programming tutorial
- python network(非常好)
- Python & Deep Belief Network
- python network packet sniffer
- ORA-24247: network access denied by access control list
- python 读 access 数据库
- 关于 iReport 的几个问题
- android 网站
- 云服务器配置
- eclipse出现Failed to load the JNI shared library
- 初学opengl(二)画散点图
- Python - access network
- js之事件冒泡和事件捕获详细介绍
- python实现网络爬虫
- 涨姿势!设计中的透视感与深度感
- iOS经典讲解之倒计时按钮JKCountDownButton的使用
- Palindrome Number
- 架构基础3-网站的高可用
- 基于近邻用户协同过滤算法的音乐推荐系统
- Unity3D-启动unity事件,切换平台监听