本文实例讲述了python实现TCP服务器端与客户端的方法。分享给大家供大家参考。具体如下:
TCP服务器程序(tsTserv.py):
from socket import *
from time import ctime
HOST = ''
PORT = 21567
BUFSIZ = 1024
ADDR = (HOST, PORT)
tcpSerSock = socket(AF_INET, SOCK_STREAM)
tcpSerSock.bind(ADDR)
tcpSerSock.listen(5)
while True:
print 'waiting for connection.
1