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

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
 
A

aaronc

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top