ScholarQuill logoScholarQuillUniversity Notes
  • Notes
  • Past Papers
  • Blogs
  • Todo
Login
ScholarQuill logoScholarQuillUniversity Notes
Login
NotesPast PapersBlogsTodo
More
SubjectsDiscussionCGPA CalculatorGPA CalculatorStudent PortalCourse Outline
About
About usPrivacy PolicyReportContact
Notes
Past Papers
Blogs
Todo
Analytics
    Current Subject
    🧩
    Computer Networks
    COMP2119
    Progress0 / 24 topics
    Topics
    1. Introduction and Protocols Architecture2. Basic Concepts of Networking3. Network Topologies4. Layered Architecture5. Physical Layer Functionality6. Data Link Layer Functionality7. Multiple Access Techniques8. Circuit Switching and Packet Switching9. LAN Technologies10. Wireless Networks11. MAC Addressing12. Networking Devices13. Network Layer Protocols14. IPv4 and IPv615. IP Addressing16. Sub Netting17. CIDR18. Routing Protocols19. Transport Layer Protocols20. Ports and Sockets21. Connection Establishment22. Flow and Congestion Control23. Application Layer Protocols24. Latest Trends in Computer Networks
    CC-214›Ports and Sockets
    Computer NetworksTopic 20 of 24

    Ports and Sockets

    3 minread
    502words
    Beginnerlevel

    Ports and sockets are fundamental concepts in networking that facilitate communication between devices over a network. They are essential for enabling applications to exchange data and provide various services. Here’s a detailed overview of ports, sockets, and how they work together.

    Ports

    Definition: A port is a numerical identifier used to differentiate between multiple services or applications running on a single device. Ports allow multiple network applications to use the same IP address without interfering with each other.

    Types of Ports

    1. Well-Known Ports:

      • Range: 0 to 1023.
      • These ports are assigned by the Internet Assigned Numbers Authority (IANA) and are used by common protocols and services.
      • Examples:
        • HTTP: Port 80
        • HTTPS: Port 443
        • FTP: Port 21
        • SMTP: Port 25
    2. Registered Ports:

      • Range: 1024 to 49151.
      • These ports can be registered with IANA for specific applications or services but are not as universally recognized as well-known ports.
      • Examples:
        • MySQL: Port 3306
        • PostgreSQL: Port 5432
    3. Dynamic or Private Ports:

      • Range: 49152 to 65535.
      • These ports are used for temporary connections and are often assigned dynamically by the operating system for client applications.
      • They are typically used for client-side applications making outbound connections.

    Sockets

    Definition: A socket is an endpoint for sending or receiving data across a network. It is a combination of an IP address and a port number, creating a unique identifier for a specific application on a device.

    Socket Components

    1. IP Address: Identifies the device on the network (e.g., 192.168.1.10).

    2. Port Number: Identifies the specific service or application on that device (e.g., 80 for HTTP).

    3. Protocol: Specifies the transport layer protocol used (TCP or UDP).

    Example of a Socket:

    • 192.168.1.10:80 (an HTTP server listening on port 80 of the device with IP address 192.168.1.10).

    How Ports and Sockets Work Together

    1. Creating a Socket:

      • When a network application starts, it creates a socket using the IP address of the device and a designated port number.
    2. Binding:

      • The application binds the socket to a specific port, allowing it to listen for incoming connections on that port.
    3. Listening for Connections:

      • For TCP connections, the application listens for incoming requests on the bound port. When a request arrives, a new socket is created to handle that specific connection.
    4. Establishing Connections:

      • For TCP, a three-way handshake occurs to establish a connection between the client and server sockets.
      • For UDP, the client sends a datagram to the server without establishing a connection.
    5. Data Transfer:

      • Once a connection is established (TCP) or a datagram is sent (UDP), data can be exchanged through the sockets until the connection is closed or the communication ends.

    Conclusion

    Ports and sockets are critical components of network communication, allowing applications to send and receive data effectively. Understanding how they work helps in developing network applications and troubleshooting network issues. If you have further questions or want to delve deeper into specific aspects of ports and sockets, feel free to ask!

    Previous topic 19
    Transport Layer Protocols
    Next topic 21
    Connection Establishment

    Past Papers

    Open this section to load past papers

    Click on Show Past Papers to see past papers.
    On This Page
      Reading Stats
      Est. reading time3 min
      Word count502
      Code examples0
      DifficultyBeginner