How can I specify which adaptor to begin listening on?
I have an application running on a PC which happens to have 2 network adaptors running on different subnets (one network for Business LAN infrastructure, one for TCP cameras)
I have a class which opens up a TCP server and listens on a specific port for connections coming in from clients on the LAN.
The problem is that my TCP server class initialises and begins listening on the adaptor which is connected to the cameras. Any connection request coming in from the Business LAN fails, it is not dealt with.
The question is, How can I specify which adaptor to begin listening on?
Code excerpt below (this is not the full class, just key methods)
Public Sub New(ByVal Name As String)
'get config
_bootStrap = New TCPServerBootstrap(Name)
'start log file
_Trace = New ACS.Utility.Logging("Connectivity." & Name & ".TcpServer." & _bootStrap.Port)
_Trace.WriteLog("TCP Server Starting")
Dim LocalIP As System.Net.IPAddress = System.Net.Dns.GetHostEntry(System.Net.Dns.GetHostName).AddressList(0)
_myListener = New TcpListener(LocalIP, _bootStrap.Port)
_Timer = New System.Timers.Timer
_Timer.Interval = 500
_Timer.Enabled = False
_name = Name
_details = _myListener.LocalEndpoint.ToString
End Sub
Public Sub BeginListening()
'Starts the listener and uses the Asynchronous 'Begin' method to handle inbound connection attempts
_Trace.WriteLog("Begin Listening on: " & _myListener.LocalEndpoint.ToString)
_myListener.Start()
_myListener.BeginAcceptSocket(New AsyncCallback(AddressOf HandleIncomingConnectionRequest), _myListener)
End Sub