Opening a Client-Side Socket for Sending Data : Client « Network « Python Tutorial






import sys
from socket import *

serverHost = 'localhost'
serverPort = 50008
message = ['Client Message1', 'Client Message2']
sSock = socket(AF_INET, SOCK_STREAM)

sSock.connect((serverHost, serverPort))

for item in message:
    sSock.send(item)
    data = sSock.recv(1024)
    print 'Client received: ', 'data'

sSock.close()








21.1.Client
21.1.1.A Minimal Client
21.1.2.Opening a Client-Side Socket for Sending Data
21.1.3.TCP Timestamp Client
21.1.4.A client that reads information from a server and display that information.