Help with client ip adress

How do I get the ip adress of a client,
because client.ip() returns the ip adress of the connected server.

when i create a server event handler,

    public void serverEvent(Server server, Client someClient) {
        System.out.println("We have a new client: " + someClient.ip());
    }

it prints the ip adress of the client, but is it possible
to create something like this on the client side?

Answers

  • edited April 2015
    • Dunno much but in order for any machine to find out its WAN IP, it needs to contact another machine over the Internet.
    • Then both machines exchange their respective IPs. But still we gotta ask the remote machine what IP it got.
    • There are many sites in the Internet that displays in text form the WAN IP of the machine which accessed it. Look for it!
  • edited April 2015

    Is there a way, my client programm can do this on it's own?
    My server gets the ip adress, I need,
    but I don't know how the client can get it's own adress,
    he is connected with (not to).

  • edited April 2015
    • As said, there are many URLs that return a text containing the WAN IP that contacted it.
    • You can include a code section in your client side which connects w/ some of those URLs.
    • Simply get the text returned and interpret it as the client's WAN IP!
  • Is there a way to get the socket what is used in the client?

  • edited April 2015

    Getting the ip from the internet isn't working, it returns the wrong ip.

    I know that the Client class contains a socket,
    and when I have a socket, I can access the ip-adress like this:
    socket.getLocalAddress().toString().substring(1)
    and I know, that you also can construct an instance of Client like this:

    Socket socket = new Socket(ip, 5204);
    client = new Client(ref.app, socket);
    

    but when I use this, my client isn't working correctly.
    It can't recieve data.
    Ideas?

  • Does someone know, why the clientEvent method is not loaded,
    when I construct a client with new Client(ref.app, socket)
    https://github.com/processing/processing/blob/master/java/libraries/net/src/processing/net/Client.java
    line 93 compared to line 131

  • Has someone experience with the .net library?

  • edited June 2016

    seems you have to change the client Class

Sign In or Register to comment.