📃
Julianne's Knowledge Base
  • README
  • Home
    • Computer Science and Programming
      • Data Structures
        • Array
        • Binary Heap
        • Binary Tree
        • Deque
        • Dynamic Array
        • Graph
        • Hash Table
        • Linked List
        • Queue
        • Stack
      • Databases
        • Database Normalization
      • Networking
        • IP Protocol
        • Network Devices
        • OSI Model and TCP/IP
        • Ethernet LAN Switching
        • IPv4 Addressing
        • Sockets
      • Operating Systems
        • UNIX Operating Systems
          • Fundamentals
            • Virtualization
              • CPU Virtualization
              • Processes
            • Processes
          • xv6
      • Software Development
        • General Tips
        • My Goals as a Software Developer
        • Programming Languages
          • C
            • Memory Management in C
          • C++
            • I/O in C++
            • Iterators
            • Memory Management in C++
          • Javascript/TypeScript
            • Inheritance
            • React
            • Useful Libraries
          • Python
        • Tools
          • GDB
          • Git
    • Cooking
      • Diet and Nutrition
      • Recipes
    • Languages
      • Japanese
        • Grammar
        • Numbers and Counting
    • Productivity
      • Getting Things Done (GTD)
      • My GTD Trigger List
      • My Personal Knowledge Management System
      • Obsidian
        • Plugins
        • Using Obsidian
Powered by GitBook
On this page
  • Internet Sockets
  • Stream Sockets
  • Datagram Sockets
  1. Home
  2. Computer Science and Programming
  3. Networking

Sockets

On UNIX systems all I/O is done by writing to file descriptors, including networking. In this case, the descriptor is referred to as a socket. There are many types of sockets, but for now we'll focus on one: Internet Sockets.

Internet Sockets

There are many types of internet sockets, but we'll focus on two for now: stream sockets and datagram sockets. Raw sockets are also important and we will look into those at a later date.

Stream Sockets

Stream sockets are two-way connected communication streams. They use TCP to ensure that data arrives sequentially and error-free.

These are used by things like Telnet and HTTP.

Datagram Sockets

Datagram sockets are considered "connectionless" and unreliable, as they use UDP for host-to-host transport. These sockets may or may not arrive at their destination, though the data will be error-free if they do arrive.

The "connectionless" part stems from the fact that an active, open connection need not be maintained like with stream sockets. To send on a datagram socket, you simply build a packet, add an IP header, send, and hope for the best.

Datagram sockets are normally used when there is no TCP stack available or when a few dropped packets isn't the end of the world.

PreviousIPv4 AddressingNextOperating Systems

Last updated 3 years ago