私は基本的にチャットアプリを作ろうとしていますが、ここではサーバーからクライアントに何も送信できません。これを修正するにはどうすればよいですか? サーバープログラム:
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