IP Address of PCs connected to my machine

C

crash.test.dummy

Hi,
I have a Swing application (running on PC1) that listens on a
specific port, but its not tied up to a particular machine, so any
machine "can connect" to PC1. It is like a chatroom application that
anyone can join in and send and receive messages (except that I'm not
running on the web).

With this, how do I know the IP addresses (LAN/WAN/frame relay) of
the machines connected to PC1?

Thanks for your help.
 
G

Gordon Beaton

I have a Swing application (running on PC1) that listens on a
specific port, but its not tied up to a particular machine, so any
machine "can connect" to PC1. It is like a chatroom application that
anyone can join in and send and receive messages (except that I'm not
running on the web).

With this, how do I know the IP addresses (LAN/WAN/frame relay) of
the machines connected to PC1?

Ask the sockets corresponding to each connection you've accepted().
Socket.getInetAddress() is what you are looking for.

/gordon
 
G

Gordon Beaton

How about:

InetAddress a = InetAddress.getByName( "some_url_arg" );

That would seem to assume that you already know who is connected,
which I believe was the original question.

/gordon
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,020
Latest member
GenesisGai

Latest Threads

Top