0
私は非常に基本的な問題があります。クライアント側はファイルを完全に受信して接続を終了しています。サーバー側は、ファイルとこのread(1024)行を閉じることに問題があります。たぶん私は間違った位置に置いています。私が思うwhileループと混同しています。これで私を導いてください。シンプルなコードは、ファイルを閉じているし、それから読み取るしようとして次のループサイクルでは、このようにエラーI/O operation on closed file
を取得し、あなたのwhile
ループでは閉じたファイルに対する入出力操作(インデントの問題)Python-ソケット
while True:
conn, addr = s.accept() # Establish connection with client.
print 'Got connection from', addr
input = raw_input("Enter 1 for accessing file and 2 for editting")
print(repr(input)) # printing input
if (input == "1"):
filename= conn.recv(1024)
f = open(filename,'rb')
l = f.read(1024)
while (1): #Keep sending it until EOF id found
conn.send(l) #Keep sending the opened file
print(repr(l))
l = f.read(1024)
f.close()