File tree Expand file tree Collapse file tree 1 file changed +22
-16
lines changed
Expand file tree Collapse file tree 1 file changed +22
-16
lines changed Original file line number Diff line number Diff line change 1- import socket
2- import tcp
1+ ## Example use of tcp v0.91 ##
2+ ## R. M. Jones ##
3+ ## 01/07/2017 ##
4+
5+ import tcp #imoprts the module that is included with this file
36
47def server ():
8+
59 data = 0
6- TCP_IP = tcp .getmyip ()
7- TCP_PORT = int (input ("Enter port: " ))
10+ TCP_IP = tcp .getmyip () #Gets your private ip address
11+ TCP_PORT = int (input ("Enter port: " )) #The port that will be open
812 BUFFER_SIZE = 20 # Normally 1024, but we want fast response
913
1014 conn = tcp .bind (TCP_IP , TCP_PORT )
1115
12- while data != "stop" :
13- data = tcp .receive (conn , BUFFER_SIZE )
14- if not data :
15- conn = tcp .bind (TCP_IP , TCP_PORT )
16- else :
17- print ("received data:" , data )
18-
19- tcp .send (data , conn )
20- #conn.send(data.encode()) # enumerate
21-
22- conn .close ()
16+
17+ data = tcp .receive (conn , BUFFER_SIZE )
18+ if not data :
19+ conn = tcp .bind (TCP_IP , TCP_PORT )
20+ else :
21+ return "received data: " + data , conn
22+
2323
24- server ()
24+ if __name__ == "__main__" :
25+ info = 0
26+ while info != "stop" :
27+ info , s = server ()
28+ print (info )
29+ tcp .send (data , s )
30+ s .close ()
You can’t perform that action at this time.
0 commit comments