+++ /dev/null
-#! /usr/bin/env python\r
-\r
-# Python implementation of an 'echo' tcp server: echo all data it receives.\r
-#\r
-# This is the simplest possible server, servicing a single request only.\r
-\r
-import sys\r
-from socket import *\r
-\r
-# The standard echo port isn't very useful, it requires root permissions!\r
-# ECHO_PORT = 7\r
-ECHO_PORT = 50000 + 7\r
-BUFSIZE = 1024\r
-\r
-def main():\r
- if len(sys.argv) > 1:\r
- port = int(eval(sys.argv[1]))\r
- else:\r
- port = ECHO_PORT\r
- s = socket(AF_INET, SOCK_STREAM)\r
- s.bind(('', port))\r
- s.listen(1)\r
- conn, (remotehost, remoteport) = s.accept()\r
- print 'connected by', remotehost, remoteport\r
- while 1:\r
- data = conn.recv(BUFSIZE)\r
- if not data:\r
- break\r
- conn.send(data)\r
-\r
-main()\r