Answers for "python and server host"

1

how to host a local python server

________________________________________________________________________________



--------------------------------------------------------------------------------
THIS IS HOW TO HOST THE SERVER :
--------------------------------------------------------------------------------
import time
import sys
import socket
import os

s = socket.socket()
host = socket.gethostname()
print(host)
port = 8080
s.bind((host,port))
print("")
print("Waiting for a device to connect...")
print("")
s.listen(5)
conn, addr = s.accept()
print (addr, " - is connected")
print ("")





--------------------------------------------------------------------------------
THIS IS HOW TO MAKE THE CLIENT FOR THE SERVER :
--------------------------------------------------------------------------------
import time
import sys
import socket
import os

s = socket.socket()
host = input("Type here hostname : ")
port = 8080
s.connect((host,port))
print("")
print("connected to server")
print("")



________________________________________________________________________________
Posted by: Guest on June-30-2021

Python Answers by Framework

Browse Popular Code Answers by Language