Forums
New posts
Articles
Product Reviews
Policies
FAQ
Log in
Register
What's new
Search
Search
Search titles only
By:
New posts
Menu
Log in
Register
Install the app
Install
Forums
macOS & iOS Developer Playground
macOS - Development and Darwin
Java Mac LINUX connection using sockets
JavaScript is disabled. For a better experience, please enable JavaScript in your browser before proceeding.
You are using an out of date browser. It may not display this or other websites correctly.
You should upgrade or use an
alternative browser
.
Reply to thread
Message
<blockquote data-quote="shellback3" data-source="post: 1430941" data-attributes="member: 206072"><p>I'm finishing up a Java package that will provide communications among a few mostly headless computers on a LAN on an aircraft but I have only two LINUX boxes to use for testing. One is the "master" and the other a client. I thought that I would use my personal mac Air as another client to see if the system would work with more than one client but it has a point of failure. When either the LINUX master attempts to get the OS-X client name (Lion or Mountain Lion) or the client attempts to get the name of the master what I get is the respective computer's IP address. I use the computer name as a key in a map.</p><p></p><p>I'm fairly new to Java and quite new to sockets.</p><p></p><p>Here's the code. ipaddress and hostname are strings</p><p></p><p>[CODE]try { </p><p> </p><p> InetAddress machine = InetAddress.getByName(ipaddress); </p><p> hostName = machine.getHostName(); </p><p>} catch (UnknownHostException e) { </p><p> Tell.sendMessage("getRemoteHostName: host name lookup failed for " + ipaddress); </p><p> </p><p>} catch (SecurityException e) { </p><p> Tell.sendMessage("getRemoteHostName: Security Exception: host name lookup failed for " + ipaddress); </p><p> </p><p>} [/CODE]</p><p></p><p>My computers are all connected to a router none is a server. </p><p></p><p>I've had no response to this question on a Java forum so thought I would try here.</p><p></p><p>Edit: no exception is thrown or caught.</p></blockquote><p></p>
[QUOTE="shellback3, post: 1430941, member: 206072"] I'm finishing up a Java package that will provide communications among a few mostly headless computers on a LAN on an aircraft but I have only two LINUX boxes to use for testing. One is the "master" and the other a client. I thought that I would use my personal mac Air as another client to see if the system would work with more than one client but it has a point of failure. When either the LINUX master attempts to get the OS-X client name (Lion or Mountain Lion) or the client attempts to get the name of the master what I get is the respective computer's IP address. I use the computer name as a key in a map. I'm fairly new to Java and quite new to sockets. Here's the code. ipaddress and hostname are strings [CODE]try { InetAddress machine = InetAddress.getByName(ipaddress); hostName = machine.getHostName(); } catch (UnknownHostException e) { Tell.sendMessage("getRemoteHostName: host name lookup failed for " + ipaddress); } catch (SecurityException e) { Tell.sendMessage("getRemoteHostName: Security Exception: host name lookup failed for " + ipaddress); } [/CODE] My computers are all connected to a router none is a server. I've had no response to this question on a Java forum so thought I would try here. Edit: no exception is thrown or caught. [/QUOTE]
Verification
Name this item 🌈
Post reply
Forums
macOS & iOS Developer Playground
macOS - Development and Darwin
Java Mac LINUX connection using sockets
Top