Socket
Sockets[edit]
Overview[edit]
Sockets are an endpoint for sending and receiving data across a computer network. They enable communication between different processes, either within the same machine or over different machines. Sockets are a key concept in network programming and are used extensively in internet communications.
Types of Sockets[edit]
There are two main types of sockets:
Stream Sockets[edit]
- Protocol: Typically use Transmission Control Protocol (TCP).
- Characteristics:
- Connection-oriented.
- Data is read in a continuous stream.
- Use Case: Ideal for scenarios where reliable communication is crucial, like file transfers or sending/receiving messages in chat applications.
Datagram Sockets[edit]
- Protocol: Usually employ User Datagram Protocol (UDP).
- Characteristics:
- Connectionless.
- Data is read in chunks (datagrams).
- Use Case: Suited for applications where speed is more critical than reliability, such as online games or streaming services.