File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -5,10 +5,12 @@ echosvr.py About the simplest TCP server possible.
55finger.py Client for the 'finger' protocol.
66ftp.py A very simple ftp client.
77gopher.py A simple gopher client.
8+ radio.py Receive time broadcasts from broadcast.py.
89telnet.py Client for the 'telnet' protocol.
910throughput.py Client and server to measure TCP throughput.
11+ unixclient.py Unix socket example, client side
12+ unixserver.py Unix socket example, server side
1013udpecho.py Client and server for the UDP echo protocol.
11- radio.py Receive time broadcasts from broadcast.py.
1214
1315The following file is only relevant on SGI machines (or other systems
1416that support multicast):
Original file line number Diff line number Diff line change 1+ # Echo client demo using Unix sockets
2+ # Piet van Oostrum
3+ from socket import *
4+ FILE = 'blabla'
5+ s = socket (AF_UNIX , SOCK_STREAM )
6+ s .connect (FILE )
7+ s .send ('Hello, world' )
8+ data = s .recv (1024 )
9+ s .close ()
10+ print 'Received' , `data`
Original file line number Diff line number Diff line change 1+ # Echo server program using Unix sockets (handles one connection only)
2+ from socket import *
3+ FILE = 'blabla'
4+ s = socket (AF_UNIX , SOCK_STREAM )
5+ s .bind (FILE )
6+ print 'Sock name is: [' + s .getsockname ()+ ']'
7+ s .listen (1 )
8+ conn , addr = s .accept ()
9+ print 'Connected by' , addr
10+ while 1 :
11+ data = conn .recv (1024 )
12+ if not data : break
13+ conn .send (data )
14+ conn .close ()
You can’t perform that action at this time.
0 commit comments