Sockets are used for interprocess communication. Interprocess communication is generally based on client-server model. In this case, client-server are the applications that interact with each other. Interaction between client and server requires a connection. Socket programming is responsible for establishing that connection between applications to interact.
- PHP Server
- Set variables such as "host" and "port"
- Create Socket
- Bind the socket to port and host
- Start listening to the socket
- Accept incoming connection
- Read the message from the Client socket
- Send message to the client socket
- Close the socket
- PHP Client
- Set variables such as "host" and "port"
- Create Socket
- Connect to the server
- Write to server socket
- Read the response from the server
- Close the socket.
- Protocol
-
User Datagram Protocol (UDP) is a network protocol that operates at the transport layer of the Internet Protocol (IP) suite.
-
How does UDP work ?
-
The implementation of the program was made using PHP Server Scripting Language.
[^1] Image