<filename>receiver.py<gh_stars>1-10
import socket
#creating socket
soc = socket.socket()
port = 181
#binding the socket to the particular port, so that any request will be connected to the particular server socket.
soc.bind(('',port))
# listen will allow no.of connections to be established
soc.listen(1)

while True:
    # accepting the connection . c here is used for sending and receiving connection , addr is the address bound to the socket.  
    c, addr = soc.accept()
    print("Connection recieved from", str(addr))
    # recv is an inbuilt-function of socket which accepts parameter of how much byte of data it can take     
    dataReceived = c.recv(4096)
    # as severs exchange data in bytes, convert data for user readability
    # converting from byte form into any other form is decoding    
    decodedMessage = dataReceived.decode()
    print(decodedMessage)
    message = "Message Received"
    # data to be sent has to be in bytes , converting data to byte is encoding    
    c.send(message.encode())
    # closing the connection    
    c.close()
    # closing connection with socket    
soc.close()
<filename>receiver.py<gh_stars>1-10
import socket
#creating socket
soc = socket.socket()
port = 181
#binding the socket to the particular port, so that any request will be connected to the particular server socket.
soc.bind(('',port))
# listen will allow no.of connections to be established
soc.listen(1)

while True:
    # accepting the connection . c here is used for sending and receiving connection , addr is the address bound to the socket.  
    c, addr = soc.accept()
    print("Connection recieved from", str(addr))
    # recv is an inbuilt-function of socket which accepts parameter of how much byte of data it can take     
    dataReceived = c.recv(4096)
    # as severs exchange data in bytes, convert data for user readability
    # converting from byte form into any other form is decoding    
    decodedMessage = dataReceived.decode()
    print(decodedMessage)
    message = "Message Received"
    # data to be sent has to be in bytes , converting data to byte is encoding    
    c.send(message.encode())
    # closing the connection    
    c.close()
    # closing connection with socket    
soc.close()
#creating socket #binding the socket to the particular port, so that any request will be connected to the particular server socket. # listen will allow no.of connections to be established # accepting the connection . c here is used for sending and receiving connection , addr is the address bound to the socket. # recv is an inbuilt-function of socket which accepts parameter of how much byte of data it can take # as severs exchange data in bytes, convert data for user readability # converting from byte form into any other form is decoding # data to be sent has to be in bytes , converting data to byte is encoding # closing the connection # closing connection with socket