【发布时间】:2012-10-25 03:30:17
【问题描述】:
我使用 python 编写了一个服务器程序。
我正在尝试获取一个字符串,但我只有一个字符! 如何接收字符串?
def handleclient(connection):
while True:
rec = connection.recv(200)
if rec == "help": #when I put help in the client program, rec = 'h' and not to "help"
connection.send("Help Menu!")
connection.send(rec)
connection.close()
def main():
while True:
connection, addr = sckobj.accept()
connection.send("Hello\n\r")
connection.send("Message: ")
IpClient = addr[0]
print 'Server was connected by :',IpClient
thread.start_new(handleclient, (connection,))
【问题讨论】:
-
你在使用非阻塞套接字吗?
标签: python sockets socketserver