我基本上是在尝试制作一个聊天应用程序,但在这里我无法从服务器向客户端发送任何内容。我该如何纠正?服务器程序:
from socket import *
host=gethostname()
port=7777
s=socket()
s.bind((host, port))
s.listen(5)
print "Server is Ready!"
while True:
c, addr= s.accept()
print c
print addr
while True:
print c.recv(1024)
s.sendto("Received",addr)
s.close()
客户端程序:
from socket import *
host=gethostname()
port=7777
s=socket()
s.connect((host, port))
while True:
s.send(( raw_input()))
prin s.recv(1024)
s.close()
它s.sendto
在服务器程序中给我错误说:
File "rserver.py", line 14, in <module>
s.sendto("Received",addr)
socket.error: [Errno 10057] A request to send or receive data was disallowed because the socket is not connected and (when sending on a datagram socket using a sendto call) no address was supplied