• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

What if ? Before I start coding.

 
Ranch Hand
Posts: 333
1
Mac Eclipse IDE Safari
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Bartender
Posts: 9626
16
Mac OS X Linux Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
reply
    Bookmark Topic Watch Topic
  • New Topic