Hi all,
I need for a program to send packets the real ip adres and not the local adres.
now i get the ip number from the local machine but this is not the internet adres.
exapmle my computer has the following adress from the router 192.168.1.102 but my internet adress is 81.58.155.112
what i need is last adres to send data to the client/server.
or is there a other trick to send?
try {
java.net.InetAddress i = java.net.InetAddress.getLocalHost();
System.out.println(i); // name and IP address
System.out.println(i.getHostName()); // name
System.out.println(i.getHostAddress()); // IP address only
}
catch(Exception e){e.printStackTrace();
}
this give me the local adres but not the internet adress.
this all is for :
public DaemonIn()
{
this.payload = new TcpSendClass();
initServerSocket();
try
{
while (true)
{
// listen for and accept a client connection to serverSocket
Socket sock = this.serverSocket.accept();
InputStream iStream = sock.getInputStream();
ObjectInputStream oiStream = new ObjectInputStream(iStream);
this.payload = (TcpSendClass)oiStream.readObject();
//this.payload =(oiStream.getClass()) oiStream.readObject();
Thread.sleep(1000);
this.payload.hashCode();
System.out.println("recived tcp class");
DaemonLog DL = new DaemonLog();
DL.WriteToLog(this.payload.getClass().getName(),"In");
}
}
catch (SecurityException se)
{
System.err.println("Unable to get client address due to security.");
System.err.println(se.toString());
System.exit(1);
}
catch (IOException ioe)
{
System.err.println("Unable to read data from an open socket.");
System.err.println(ioe.toString());
System.exit(1);
}
catch (InterruptedException ie) { } //
Thread sleep interrupted
catch (ClassNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
finally
{
try
{
this.serverSocket.close();
}
catch (IOException ioe)
{
System.err.println("Unable to close an open socket.");
System.err.println(ioe.toString());
System.exit(1);
}
}
System.out.println("Received payload:");
System.out.println(this.payload.toString());
}
and a reciver but the reciver needs to send back for that i need the adress of the client computer.
please help...