Listening and Establish TCP connections on/from the same IP end po

  • Thread starter Thread starter aaronc
  • Start date Start date
A

aaronc

Hi,

I have an application that needs to use the same IP end point to both listen
and accept client connections as well as be able to establish connections to
external TCP sockets. The application is a SIP server and the requirement it
has is to be able to accept SIP requests from clients and then to forward
those requests onto additional SIP servers.

The application needs to listen on a specific port because that's where the
clients will be attempting to connect. For the outgoing calls it needs to use
the same port, 5060, as a lot of firewalls will be configured to accept
traffic originating from 5060 and drop anything else.

With UDP it's simple to listen and send from the same IP end point but as
yet I have not been able to find a way to do it with TCP.

Thanks,

Aaron
 
aaronc said:
Hi,

I have an application that needs to use the same IP end point to both listen
and accept client connections as well as be able to establish connections to
external TCP sockets. The application is a SIP server and the requirement it
has is to be able to accept SIP requests from clients and then to forward
those requests onto additional SIP servers.

The application needs to listen on a specific port because that's where the
clients will be attempting to connect. For the outgoing calls it needs to use
the same port, 5060, as a lot of firewalls will be configured to accept
traffic originating from 5060 and drop anything else.

With UDP it's simple to listen and send from the same IP end point but as
yet I have not been able to find a way to do it with TCP.

Turned out to be very easy after all...

socket.SetSocketOption(SocketOptionLevel.Socket,
SocketOptionName.ReuseAddress, true);

Regards,

Aaron
 
Back
Top