1. tensorpudding
  2. toybox

Commits

Michael  committed a2e83f3 Merge

Automated merge with ssh://hg@bitbucket.org/tensorpudding/toybox

  • Participants
  • Parent commits b7f7c2a, 7e2baa5
  • Branches default

Comments (0)

Files changed (2)

File python/echoclient.py

View file
+#!/usr/bin/env python
+
+import socket
+
+host = 'localhost'
+port = 8080
+size = 1024
+
+s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
+s.connect((host,port))
+s.send('Hello World!')
+data = s.recv(size)
+s.close
+print 'Received:', data

File python/echoserver.py

View file
+#!/usr/bin/env python
+
+import socket
+
+host = ''
+port = 8080
+
+backlog = 5
+size = 1024
+
+s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
+s.bind((host,port))
+s.listen(backlog)
+while 1:
+    client, address = s.accept()
+    data = client.recv(size)
+    if data:
+        client.send(data)
+    client.close()
+