This example uses the socket module to:
- open a socket
- send a string
- wait for reply
- close the socket
from socket import *
ip='localhost'
port=9901
csock=socket(AF_INET,SOCK_STREAM)
csock.settimeout(1.0)
csock.connect( (ip,port) )
csock.send('PartPresent')
reply = csock.recv(100)
csock.close() Note 1: Example 23
shows a socket server implementation |