Win a copy of Cross-Platform Desktop Applications: Using Node, Electron, and NW.js this week in the JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

What if ? Before I start coding.  RSS feed

 
David Garratt
Ranch Hand
Posts: 216
Eclipse IDE Mac Safari
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Lets assume I need to send some ASCII data to a Ethernet to Serial Device on a network. I know it's IP and Port Number. No problems there.

Now I also need to wait for a reply from the device to say if it's happy with what I've sent it. Again - not such a chore.

HOWEVER.

The server running this application has 4 network cards in it. Each network card is connected to a separate VLAN. The TCP/IP settings for each network card (Windows 2003) specifies only 1 gateway address on one of the cards. So far so good.

Assuming that the network has been set-up correctly my outbound connection to SEND data will be sent via the gateway and make a connection to the remote machine.

Now lets assume I want a separate thread to handle the reply coming back. I know the port number that I am listening on - but do I need to know the interface (network card) that will be receiving the reply. I know it's the one that the gateway address is specified, but my program does not ? Does that matter ? Do I need to listen against a specific interface ?

Thanks

Dave
 
Joe Ess
Bartender
Posts: 9425
12
Linux Mac OS X Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
David Garratt wrote:
Now lets assume I want a separate thread to handle the reply coming back. I know the port number that I am listening on - but do I need to know the interface (network card) that will be receiving the reply. I know it's the one that the gateway address is specified, but my program does not ? Does that matter ? Do I need to listen against a specific interface ?


So your client is making a new connection back to the server, not holding on to the original connection?
My gut reaction is no, you do not have to consider the interface because that is a network-level detail and is handled by the OS. The client is going to be on the other side of the gateway and the other interfaces will not even be addressable.
However, I'll move this to the sockets forum so we can get some other eyeballs on the problem.
 
Steve Harney
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

As Joe stated it depends on if the serial device is making a secondary conection or if its using the existing connection.

If you are reusing the connection there is no need to worry about the incoming message you can just re use your connection and read from it.

If the device is connecting back to your server then you can specify where to bind your ServerSocket, by default it will accept connections on any local addresses. otherwise you can specify addresses and it will only listen on those addresses,

for example if you bind to the 127.0.0.1 (ipv4) you will only be bound to loop back adaptor.
or if you bind to one of the ip addreses you will only receive connection directed to that adaptor.

Steve
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!