add example using select/asyncore from http://etutorials.org/Programming/Python+tutorial/Part+IV+Network+and+Web+Programming/Chapter+19.+Sockets+and+Server-Side+Network+Protocol+Modules/19.3+Event-Driven+Socket+Programs/
This commit is contained in:
13
TcpClient.py
Normal file
13
TcpClient.py
Normal file
@@ -0,0 +1,13 @@
|
||||
import socket
|
||||
sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
|
||||
sock.connect(('localhost', 8881))
|
||||
print "Connected to server"
|
||||
data = """A few lines of data
|
||||
to test the operation
|
||||
of both server and client."""
|
||||
for line in data.splitlines( ):
|
||||
sock.sendall(line+'\n')
|
||||
print "Sent:", line
|
||||
response = sock.recv(8192)
|
||||
print "Received:", response
|
||||
sock.close( )
|
||||
Reference in New Issue
Block a user