Skip to content

Commit 9e7a2fa

Browse files
author
parita pooj
committed
multiple client chat
1 parent f15ffb6 commit 9e7a2fa

1 file changed

Lines changed: 7 additions & 6 deletions

File tree

socket-programming/echo-server.py

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,11 @@
1212
data ='initialised...'
1313
input_ = [server_socket]
1414
output = [server_socket]
15-
inputready,outputready,exceptready = select.select(input_,output,[])
16-
print len(inputready) , len(input_), len(outputready), len(output)
17-
while 1:
15+
16+
while 1:
17+
inputready,outputready,exceptready = select.select(input_,output,[])
18+
print len(inputready) , len(input_), len(outputready), len(output)
19+
1820
for s in inputready:
1921
if s==server_socket:
2022
client, address = server_socket.accept()
@@ -23,16 +25,14 @@
2325

2426
else:
2527
if data:
26-
s.send(data)
28+
s.send(data)
2729
data=s.recv(1024)
2830
print "received:",data
2931
if data:
3032
print "out of inputready"
3133
break;
3234
else:
3335
input_.remove(s)
34-
inputready,outputready,exceptready = select.select(input_,output,[])
35-
print len(inputready) , len(input_), len(outputready), len(output)
3636
inputready,outputready,exceptready = select.select(input_,output,[])
3737
print len(inputready) , len(input_), len(outputready), len(output)
3838
for s in outputready:
@@ -48,5 +48,6 @@
4848
s.close()
4949
inputready,outputready,exceptready = select.select(input_,output,[])
5050
print len(inputready) , len(input_), len(outputready), len(output)
51+
data=''
5152

5253

0 commit comments

Comments
 (0)