Networking with Python
Networking with Python
Thomas Schwarz, SJ
Socket Programming In Python
? Python translates the UNIX socket interface
? IPv4: Use a tuple IP-address, port number
? Sockets go through a life cycle:
? Creation, Connection, Receiving / Sending, Closing
? Creation, Binding, Listening, Closing
Socket Programming In Python
? Example:
? A simple writer to another process
? Data is send as a byte stream
? Using local-loop to avoid opening the rewall
? Otherwise: Go to rewall administration and create a
new rule to open port 61234 for TCP
? Afterwards: remove this rule
if if
Socket Programming In Python
? Server:
? Create socket
? using ipv4 (AF_INET) and TCP
import socket HOST = '127.0.0.1' #Loopback interface PORT = 65431 #Silly port with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as s:
Socket Programming In Python
? Bind socket to port and listen
with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as s: s.bind((HOST, PORT)) s.listen() conn, addr = s.accept()
................
................
In order to avoid copyright disputes, this page is only a partial summary.
To fulfill the demand for quickly locating and searching documents.
It is intelligent file search solution for home and business.
Related download
- python lesson 6 fileinput and output github pages
- network programming with python python 101 lip6
- the unicode standard version 15
- if you have to process difficult characters utf 8 encoding and sas
- xml character encoding and decoding xfront
- ibm open enterprise python for z os v3 8 user s guide
- networking with python
- unicode convertfile — low level file conversion between encodings
- programming with unicode documentation read the docs
- unicode encoding — unicode encoding utilities stata
Related searches
- networking with grace eden prairie
- python lambda with arguments
- python call executable with arguments
- python datetime with timezone
- python random choice with probability
- update python packages with pip
- python with spyder
- python import with path
- does python come with pip
- python os delete directory with files
- python create filename with date time stamp
- python format float with comma