Python 2 examples taken while learning SPSE
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

21 lines
436 B

5 years ago
#!/usr/bin/python
# -*- coding: utf-8 -*-
import socket
tcpSocket = socket.socket(socket.AF_INET, socket.SOCK_STREAM) # TCP - STREAM
tcpSocket.bind(("127.0.0.1", 8001)) # Should be passed as tuple
tcpSocket.listen(2) # 2 is the number of concurr to handle
(client, ( ip, port)) = tcpSocket.accept() # accept by default is blocking call
# client.send("Message to client.")
data = client.recv(2048)
print ip
print port
print data