Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import socket
- import sys
- # Create a TCP/IP socket
- sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
- # Connect the socket to the port where the server is listening
- server_address = ('localhost', 8764)
- sock.connect(server_address)
- # Listen for incoming connections
- sock.listen(1)
- while True:
- # Wait for a connection
- print 'waiting for a connection'
- connection, client_address = sock.accept()
- try:
- print 'connection from', client_address
- while True:
- data = connection.recv(8)
- print 'received: %s' % data
- except:
- print 'error'
Advertisement
Add Comment
Please, Sign In to add comment