????3. Python Socket Client
??????????????

 

# -*- coding:utf-8 -*-
from socket import *
def SocketClient():
try:
#????socket????
s=socket(AF_INET??SOCK_STREAM??0)
Colon = ServerUrl.find(':')
IP = ServerUrl[0:Colon]
Port = ServerUrl[Colon+1:]
#????????
s.connect((IP??int(Port)))
sdata='GET /Test HTTP/1.1
Host: %s '%ServerUrl
print "Request: %s "%sdata
s.send(sdata)
sresult=s.recv(1024)
print "Response: %s " %sresult
#???Socket
s.close()
except Exception??ex:
print ex
ServerUrl = "192.168.16.15:9999"
SocketClient()

????4. ???н??
????Socket Server?????н?????£?

????Socket-Server
????Socket Client?????н?????£?