Skip to content

Instantly share code, notes, and snippets.

@PratyushMishra02
Last active July 29, 2020 09:03
Show Gist options
  • Save PratyushMishra02/b3242b9b72194effa41b8b8fbe0a09fd to your computer and use it in GitHub Desktop.
Save PratyushMishra02/b3242b9b72194effa41b8b8fbe0a09fd to your computer and use it in GitHub Desktop.
import socket
import sys
import time
s=socket.socket()
host=socket.gethostname()
print("Server will start on host:",host)
port=1234
s.bind((host,port))
print("Server is bound successfully")
s.listen(1)
conn,addr=s.accept()
print(addr,"has connected")
while 1:
message=input(str("You:>>"))
message=message.encode()
conn.send(message)
incoming_message=conn.recv(1024)
incoming_message=incoming_message.decode()
print("Client:>>",incoming_message)
Just open host and copy your name, paste it on another server and start chatting : )
import socket
import sys
import time
s=socket.socket()
host=socket.gethostname()
print("Server will start on host:",host)
port=1234
s.bind((host,port))
print("Server is bound successfully")
s.listen(1)
conn,addr=s.accept()
print(addr,"has connected")
while 1:
message=input(str("You:>>"))
message=message.encode()
conn.send(message)
incoming_message=conn.recv(1024)
incoming_message=incoming_message.decode()
print("Client:>>",incoming_message)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment