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.
• Socket Chat Room was a little project for socket study. It works with a server handling the incoming connections from the clients. Clients send encoded messages while waiting for others clients mes
The WiFiWart is an open source WiFi penetration device masquerading as a regular wall charger. It features a 1.2Ghz Cortex A7 MPU with two WiFi chips onboard.
WebRecon is an automatic web reconnaissance tool written in python3. Provides a command line interaction similar to msfconsole. The Exasmple.py file is provided, and you can write your own scripts yo
wireguard-config-benchmark is a python script that benchmarks the download speeds for the connections defined in one or more wireguard config files. If multiple configs are benchmarked it will output
This repository contain sample code of gRPC Communication between Python and GoLang, the Server is running on GoLang while Python is running the client
Building a Robust IOT device which is customizable, encrypted, secure and user friendly, which uses a single GPIO pin to extract multiple sensor values