import socket
HOST = "127.0.0.1"
PORT = 5000
mySocket = socket.socket( socket.AF_INET, socket.SOCK_STREAM )
try:
mySocket.connect( ( HOST, PORT ) )
except socket.error:
print "Call to connect failed"
serverMessage = mySocket.recv( 1024 )
while serverMessage != "TERMINATE":
if not serverMessage:
break
print serverMessage
clientMessage = "1234"
mySocket.send( clientMessage )
serverMessage = mySocket.recv( 1024 )
mySocket.close()
|