This repository was archived by the owner on Aug 21, 2018. It is now read-only.
File tree 1 file changed +32
-0
lines changed
1 file changed +32
-0
lines changed Original file line number Diff line number Diff line change
1
+ import socket
2
+ import sys
3
+
4
+ # this listens to notification stream from MSE and displays results in console.
5
+
6
+ # Create a TCP/IP socket
7
+ sock = socket .socket (socket .AF_INET , socket .SOCK_STREAM )
8
+
9
+ # Bind the socket to the address given on the command line
10
+ server_address = ('0.0.0.0' , 8000 ) # change this to your ip address
11
+ sock .bind (server_address )
12
+ # print >>sys.stderr, 'using %s port %s' % sock.getsockname() # use this print statement for python2.7
13
+ print (sys .stderr ,'using %s port %s' % sock .getsockname ()) # use this print statement for python3
14
+ sock .listen (1 )
15
+
16
+ while True :
17
+ print (sys .stderr , 'waiting for a connection' ) # use this print statement for python3
18
+ # print >>sys.stderr, 'waiting for a connection' # use this print statement for python2.7
19
+ connection , client_address = sock .accept ()
20
+ try :
21
+ #print >>sys.stderr, 'client connected:', client_address # use this print statement for python2.7
22
+ print (sys .stderr , 'client connected:' , client_address ) # use this print statement for python3
23
+ while True :
24
+ data = connection .recv (1024 ) # change this value, based on your needs.
25
+ print (sys .stderr , 'received "%s"' % data ) # use this print statement for python3
26
+ #print >>sys.stderr, 'received "%s"' % data # use this print statement for python2.7
27
+ if data :
28
+ connection .sendall (data )
29
+ else :
30
+ break
31
+ finally :
32
+ connection .close ()
You can’t perform that action at this time.
0 commit comments