Binding the port number.

Hi all,

 Application A is using an port number 100 and is binded to an interface 1. 

 Application B is using an port number 100 and is binded to an interface 2.

 can we bind the two applications on same port number based on interfaces.

 what i want to know is two applications using two interfaces can use the same port number.

Thanks in advance........

Tried starting httpd on a port already in use for a tcp session and it seems to work.

user@computer:/home/user# netstat -an | head -n4
Active Internet connections (servers and established)
Proto Recv-Q Send-Q Local Address           Foreign Address         State      
tcp        0      0 192.168.22.1:48135      0.0.0.0:*               LISTEN
tcp        0      0 192.168.30.2:48135       74.125.47.156:80        ESTABLISHED

Yes, you can do that.

The ports do not have to be unique for the server, only for the address. It does not even matter if the address is on a real or logical interface.

Hi,

   We can use the same port number for two applications based on protocols.\(i.e  one application is based on TCP and the other application based on UDP\).         

But i don't know about interfaces, can anyone one help........

   1\) Can we use same port number for different applications on a single interface.

   2\) Can we use same port number for different applications on different  interfaces\(interfaces have separate ip address\).


   Consider that same port number can be used on different applications, then won,t it be a problem in receiving the packets.

           Applications using UDP protocol.
          \--------------------------------

                  1\) Application 1 is binded to the port number 1500 and ip address of an interface.\(Transfer the packet through the selected interface\).

                  2\) Application 2 is binded to the port number 1500 and ip address is 0.0.0.0

            Now, inorder to transfer the packet of Application 2 an interface has to be selected based on destination's ip address. 
           If application 2 want's to transfer packets with different destination ip adresses, then different interfaces will be selected for different interfaces.\(so application 2 may transfer packet through any one of the available interface and where as application 1 will transfer through the specific interface\).

          --->After receiving  the packet, how should i select the socket of application 1 and application 2.

                        Problem is both sockets are binded to same port number and interface on which application 2 is transferring the packets are not fixed.