450 likes | 1.36k Views
Socket Programming in Python. Lloyd Jones. Sockets in Python. Great for cross-platform communication Fast form of IPC Can use send/ recv or read/write Bind, Listen, Accept Connections, Close. Explanation. Line 10: Create a server socket
E N D
Socket Programming in Python Lloyd Jones
Sockets in Python • Great for cross-platform communication • Fast form of IPC • Can use send/recv or read/write • Bind, Listen, Accept Connections, Close
Explanation • Line 10: Create a server socket • Line 11: Bind the socket to any address that the machine has using the specified port • Line 12: Begin listening on the socket, queue up “backlog” number of requests (5 in this case) • Lines 13-23: Main loop. Accepts connection reads in up to 1024 bytes. If data sent = “letmein”, then print a welcome message.