Socket programming is a way of connecting two nodes on a network to communicate with each other. One socket(node) listens on a particular port at an IP, while the other socket reaches out to the other to form a connection. The server forms the listener socket while the client reaches out to the server.
Socket Programming Digram :
1:- Server
# first of all import the socket libraryimportsocket# next create a socket objectsocket_obj=socket.socket()# Next bind to the portsocket_obj.bind(('localhost',8002))# put the socket into listening modesocket_obj.listen(4)# Establish connection with client.client_obj,address=socket_obj.accept()# receive data from clientrecv_msg=client_obj.recv(1024)# Decode datarecv_msg.decode('utf-8')# Print Dataprint(recv_msg)# Close the connection with the clientsocket_obj.close()
1:- Client
# import the socket libraryimportsocket# Create a socket objectsocket_obj=socket.socket()# connect to the server using host and portsocket_obj.connect(('localhost',8002))# input datamsg=str(input("Entter your message : "))# encode and send the data from input datasocket_obj.send(msg.encode('utf-8'))
Here is the final result :
Owner
Janak raikhola
Actions do not cling to me because I am not attached to their results. Those who understand this and practise it live in freedom.
This is a python based command line Network Scanner utility, which input as an argument for the exact IP address or the relative IP Address range you wish to do the Network Scan for and returns all t