diff options
| author | Comment <tim@gray.(none)> | 2012-11-28 18:40:32 +0000 |
|---|---|---|
| committer | Comment <tim@gray.(none)> | 2012-11-28 18:40:32 +0000 |
| commit | a0ab2cd35d91ba0080f9fb870d82aa90a51a0d6c (patch) | |
| tree | 0e0fd44d0f07ccf1ea4a5f1e30a03e0203300321 /vpn/TCPserver.py | |
| parent | 75c277c10f206f5bf3799caa03a52f40c1c8b6cf (diff) | |
nearly finished except latency
Diffstat (limited to 'vpn/TCPserver.py')
| -rwxr-xr-x | vpn/TCPserver.py | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/vpn/TCPserver.py b/vpn/TCPserver.py new file mode 100755 index 0000000..be0ce17 --- /dev/null +++ b/vpn/TCPserver.py @@ -0,0 +1,30 @@ +#!/usr/bin/python + +import SocketServer + +class MyTCPHandler(SocketServer.BaseRequestHandler): + """ + The RequestHandler class for our server. + + It is instantiated once per connection to the server, and must + override the handle() method to implement communication to the + client. + """ + + def handle(self): + # self.request is the TCP socket connected to the client + self.data = self.request.recv(1024).strip() + print "{} wrote:".format(self.client_address[0]) + print self.data + # just send back the same data, but upper-cased + self.request.sendall(self.data.upper()) + +if __name__ == "__main__": + HOST, PORT = "", 5000 + + # Create the server, binding to localhost on port 9999 + server = SocketServer.TCPServer((HOST, PORT), MyTCPHandler) + + # Activate the server; this will keep running until you + # interrupt the program with Ctrl-C + server.serve_forever()
\ No newline at end of file |
