Socket: Difference between revisions

From Computer Science Wiki
No edit summary
No edit summary
Line 1: Line 1:
= Sockets =
== Overview ==
== Overview ==
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.
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.

Revision as of 23:59, 22 January 2024

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.