python socket server程序在不同系统上编写方法不一样,是吗
# -*- coding: utf-8 -*-import socket
import datetime
HOST=''
PORT=21567
BUFSIZ = 1024
ADDR = (HOST,PORT)
tcpSerSock = socket(socket.AF_INET,socket.SOCK_STREAM)
tcpSerSock.bind(ADDR)
tcpSerSock.listen(5)
while True:
print 'waiting for connection...'
tcpCliSock, addr = tcpSerSock.accept()
print '...connectde from:',addr
while True:
data = tcpCliSock.recv(BUFSIZ)
if not data:
break
tcpCliSock.send('[%s] %s' %(
ctime(),data))
tcpCliSock.close()
tcpSerSock.close()
我写成这样后,它报错了: File "F:\Program Files\python\ts Tserv.py", line 11, in <module>
tcpSerSock = socket(socket.AF_INET,socket.SOCK_STREAM)
TypeError: 'module' object is not callable
qing bang mang jiejue.xieixe !