質問
例外の理由は何ですか?
クライアントによってエラーが発生しましたか?
可能であれば、他のエラーを説明してください。
バックグラウンド
Python GUI ソケット サーバーを作成しています。クライアントが私のサーバーに接続すると、GUI ウィンドウが開きます (私はまだこれに取り組んでいます)。しかし、クライアントが接続すると、エラーが発生します。
Unhandled exception in thread started by <function clientthread at 0x10246c230>
実際のスクリプトはかなり長いので、ペーストビンのリンクを提供しました。
スレッドコードはこちら。私のオブジェクトs
の名前です。socket
def clientthread(s):
#Sending message to connected client
#This only takes strings (words
s.send("Welcome to the server. Type something and hit enter\n")
#loop so that function does not terminate and the thread does not end
while True:
#Receiving from client
data = s.recv(1024)
if not data:
break
s.sendall(data)
print data
s.close()
トレースバック
提案してくれてありがとうMorten。これがトレースバックです。
Socket Created
Socket Bind Complete
Socket now listening
Connected
Traceback (most recent call last):
File "/Users/BigKids/Desktop/Coding/Python 2/Sockets/Function/Server GUI Alpha Function.py", line 80, in clientthread
s.send("Welcome to the server. Type something and hit enter\n")
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/socket.py", line 170, in _dummy
raise error(EBADF, 'Bad file descriptor')
error: [Errno 9] Bad file descriptor
個人的には、多くのエラーは GUI によるものだと思います。
ありがとう!