aspose file tools*
The moose likes Sockets and Internet Protocols and the fly likes ethernet-to-serial Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » Sockets and Internet Protocols
Bookmark "ethernet-to-serial" Watch "ethernet-to-serial" New topic
Author

ethernet-to-serial

Diego Gil
Greenhorn

Joined: Dec 08, 2004
Posts: 1
I was searching, without results, for a java code that emulate these ethernet-to-serial devices.

That is a computer B with a ethernet and a serial port and another computer A with just a ethernet port.

A "device driver" in A simulates a serial port. All information sended to this port goes to ethernet port in B and routed internally to serial port with proper handshaking. The same for reading.

I saw hardware devices but I am looking for a softwate emulation, in java.

Any idea ?.

Thanks.
Elliotte Rusty Harold
author
Ranch Hand

Joined: Feb 25, 2004
Posts: 91
Java doesn't have access to the TCP/IP stack below the transport layer, so you really can't write anything that requires direct access to the Ethernet hardware in Java. Sorry. :-(


Elliotte Rusty Harold<br />Author of <a href="http://cafe.elharo.com/web/refactoring-html/" target="_blank" rel="nofollow">Refactoring HTML</a>
Stan James
(instanceof Sidekick)
Ranch Hand

Joined: Jan 29, 2003
Posts: 8791
Going off topic, that rattled a bit in my brain ... if a PC has two network cards and I open a server socket, how do we know which card / network / protocol will see the port as accessible?


A good question is never answered. It is not a bolt to be tightened into place but a seed to be planted and to bear more seed toward the hope of greening the landscape of the idea. John Ciardi
Alexandru Popescu
Ranch Hand

Joined: Jul 12, 2004
Posts: 995
If I remember well it is a JVM parameter that instructs which is the default network card to be used.

./pope


blog - InfoQ.com
Elliotte Rusty Harold
author
Ranch Hand

Joined: Feb 25, 2004
Posts: 91
By default, a ServerSocket will listen on all available network interfaces, including each Ethernet card and localhost, as well as all virtual IP addresses mapped to the Ethernet cards. You can restrict this by IP or hostname. This example is taken from Chapter 10, Sockets for Servers:

For example, login.ibiblio.org is a particular Linux box in North Carolina. It�s connected to the Internet with the IP address 152.2.210.122. The same box has a second Ethernet card with the local IP address 192.168.210.122 that is not visible from the public Internet, only from the local network. If for some reason I wanted to run a server on this host that only responded to local connections from within the same network, I could create a server socket that listens on port 5,776 of 192.168.210.122 but not on port 5,776 of 152.2.210.122, like so:

Stan James
(instanceof Sidekick)
Ranch Hand

Joined: Jan 29, 2003
Posts: 8791
Ah, makes sense each card would have its own IP address. Hard to believe I actually passed a network class once I was wondering if we could tie this back to the original request and make a Java software ethernet-to-serial solution, or any kinda input to any kinda output. That is pretty much the whole magic of "inter" in the Internet.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: ethernet-to-serial