Advertisement
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)
- # Bind the socket to the port
- server_address = ('localhost', 10000)
- print('starting up on {} port {}'.format(*server_address))
- sock.bind(server_address)
- # Listen for incoming connections
- sock.listen(5)
- while True:
- # Wait for a connection
- print('waiting for a connection')
- connection, client_address = sock.accept()
- try:
- print('connection from', client_address)
- # Receive the data in small chunks and retransmit it
- while True:
- data = connection.recv(8)
- if data.decode() == "Conectei":
- print("Vlw")
- finally:
- # Clean up the connection
- connection.close()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement