Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9155407
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T12:35:13+00:00 2026-06-17T12:35:13+00:00

While studying computer networks as the course subject, my concept was that operating system

  • 0

While studying computer networks as the course subject, my concept was that operating system distinguishes a packet based on the destination port and delivers it to application which is running on that port.

Later I came to know that we can connect to two different destinations (DestinationIP:DestinationPort) using the same source(SourceIP:SourcePort).

tcp        0      0 192.168.1.5:60000       199.7.57.72:80          ESTABLISHED 1000       196102      10179/firefox
tcp        0      0 192.168.1.5:60000       69.192.3.67:443         ESTABLISHED 1000       200361      10179/firefox
tcp        0      0 192.168.1.5:60000       69.171.234.18:80        ESTABLISHED 1000       196107      10179/firefox
tcp        0      0 192.168.1.5:60000       107.21.19.182:22        ESTABLISHED 1000       196399      10722/ssh
tcp        0      0 192.168.1.5:60000       69.171.234.18:443       ESTABLISHED 1000       201792      10179/firefox
tcp        0      0 192.168.1.5:60000       69.192.3.34:443         ESTABLISHED 1000       200349      10179/firefox
tcp        0      0 127.0.0.1:4369          127.0.0.1:51889         ESTABLISHED 129        12036       1649/epmd
tcp        0      0 192.168.1.5:60000       69.192.3.58:443         ESTABLISHED 1000       200352      10179/firefox
tcp        0      0 192.168.1.5:60000       74.125.236.88:80        ESTABLISHED 1000       200143      10179/firefox
tcp        0      0 192.168.1.5:60000       174.122.92.78:80        ESTABLISHED 1000       202935      10500/telnet
tcp        0      0 192.168.1.5:60000       74.125.236.87:80        ESTABLISHED 1000       201600      10179/firefox

Going little more into depths, I came to know that if an application uses bind() system call to bind a socket descriptor with a particular IP and port combination, then we can’t use the same port again. Otherwise if a port is not binded to any socket descriptor, we can use the same port and IP combination again to connect to a different destination.

I read in the man page of bind() syscall that

   bind() assigns the address specified to by addr to the socket referred to by the file descriptor sockfd.

My question are:

  1. When we don’t call bind() syscall generally while writing a client program then how does the OS automatically selects the port number.

  2. When two different applications use the same port and IP combination to connect to two different servers and when those servers reply back, how does the OS finds out that which packet needs to be redirected to which application.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T12:35:14+00:00Added an answer on June 17, 2026 at 12:35 pm

    When we don’t call bind() syscall generally while writing a client
    program then how does the OS automatically selects the port number

    The OS picks a random unused port (not necessarily the "next" one).

    how does the OS finds out that which packet needs to be redirected to
    which application

    Each TCP connection is identified by a 4-tuple: (src_addr, src_port, dst_addr, dst_port) which is unique and thus enough to identify where each segment belongs.

    EDIT

    When we don’t call bind() syscall generally while writing a client
    program then how does the OS automatically selects the port number.

    Sometime before "connecting" in the case of a TCP socket. For example, Linux has the function inet_csk_get_port to get an unused port number. Look for inet_hash_connect in tcp_v4_connect.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

while i'm studying the operating system course i didnt understand why the output of
While I am studying the new django docs on class-based views, I notice this
While studying the Collection API, we find that some methods ( add , remove
I am studying the SCJP, and while studying I have found an exercise that
While studying the Qt framework, I've noticed that it's littered with hundreds of overloaded
while studying some security things, there was a question that one can guess the
While studying natural language processing I've come across the subject of Conceptual Dependencies. I've
I was asked to add a module to existing system. While studying the structure,
While studying for a Functional Programming exam, I came across the following questions from
While studying for a Functional Programming exam, I came across the following question from

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.