|
8 | 8 |
|
9 | 9 | print "TCPServer Waiting for client on port 5000" |
10 | 10 |
|
11 | | -data ='' |
| 11 | + |
| 12 | +data ='initialised...' |
12 | 13 | input_ = [server_socket] |
13 | 14 | output = [server_socket] |
14 | 15 | inputready,outputready,exceptready = select.select(input_,output,[]) |
| 16 | +print len(inputready) , len(input_), len(outputready), len(output) |
15 | 17 | while 1: |
16 | | - |
17 | | - print len(inputready) , len(input_), len(outputready), len(output) |
18 | | - for s in inputready: |
19 | | - |
20 | | - print s.getsockname() |
21 | | - if s==server_socket: |
22 | | - client, address = server_socket.accept() |
23 | | - print "I got a connection from ", address |
24 | | - input_.append(client) |
25 | | - else: |
26 | | - data = s.recv(1024) |
27 | | - if data: |
28 | | - s.send(data) |
29 | | - print 'received:',data |
30 | | - else: |
31 | | - s.close() |
32 | | - input_.remove(s) |
33 | | - print "Mistake idhar hai kya ?" |
34 | | - inputready,outputready,exceptready = select.select(input_,output,[]) |
| 18 | + for s in inputready: |
| 19 | + if s==server_socket: |
| 20 | + client, address = server_socket.accept() |
| 21 | + print "I got a connection from ", address |
| 22 | + input_.append(client) |
| 23 | + |
| 24 | + else: |
| 25 | + if data: |
| 26 | + s.send(data) |
| 27 | + data=s.recv(1024) |
| 28 | + print "received:",data |
| 29 | + if data: |
| 30 | + print "out of inputready" |
| 31 | + break; |
| 32 | + else: |
| 33 | + input_.remove(s) |
| 34 | + inputready,outputready,exceptready = select.select(input_,output,[]) |
| 35 | + print len(inputready) , len(input_), len(outputready), len(output) |
| 36 | + inputready,outputready,exceptready = select.select(input_,output,[]) |
| 37 | + print len(inputready) , len(input_), len(outputready), len(output) |
| 38 | + for s in outputready: |
| 39 | + if s==server_socket: |
| 40 | + client, address = server_socket.accept() |
| 41 | + print "I got a connection from ", address |
| 42 | + output.append() |
| 43 | + else: |
| 44 | + if data: |
| 45 | + s.send(data) |
| 46 | + output.remove(s) |
| 47 | + else: |
| 48 | + s.close() |
| 49 | + inputready,outputready,exceptready = select.select(input_,output,[]) |
| 50 | + print len(inputready) , len(input_), len(outputready), len(output) |
| 51 | + |
| 52 | + |
0 commit comments