Skip to content

Instantly share code, notes, and snippets.

@BMU-Verlag
Created January 21, 2020 13:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save BMU-Verlag/b0db12efa26738593149ce970d70594f to your computer and use it in GitHub Desktop.
Save BMU-Verlag/b0db12efa26738593149ce970d70594f to your computer and use it in GitHub Desktop.
# server.py
from header_utils import format_message
import socket
server_socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
server_socket.bind((socket.gethostname(), 5555))
server_socket.listen(10)
print (f'Listeing on {socket.gethostname()}:{5555}')
while True:
client_socket, client_address = server_socket.accept()
print(f'Established connection to {client_address[0]}:{client_address[1]}')
client_socket.send(bytes(format_message('Hello there, how are you?'), 'utf-8'))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment