How do I send data between two computers over the internet

Posted by Johan on Stack Overflow See other posts from Stack Overflow or by Johan
Published on 2011-02-26T15:14:20Z Indexed on 2011/02/26 15:24 UTC
Read the original article Hit count: 195

Filed under:
|

I have been struggling with this for the entire day now, I hope somebody can help me with this.

My problem is fairly simple: I wish to transfer data (mostly simple commands) from one PC to another over the internet.

I have been able to achieve this using sockets in Java when both computers are connected to my home router. I then connected both computers to the internet using two different mobile phones and attempted to transmit the data again. I used the mobile phones as this provides a direct route to the internet and if I use my router I have to set up port forwarding, at least, that is how I understand it.

I think the problem lies in the method that I set up the client socket. I used:

Socket kkSocket = new Socket(ipAddress, 3333);

where ipAddress is the IP address of the computer running the server. I got the IP address by right-clicking on the connection, status, support. Is that the correct IP address to use or where can I obtain the address of the server? Also, is it possible to get a fixed name for my computer that I can use instead of entering the IP address, as this changes every time I connect to the internet using my mobile phone?

Alternatively, are there better methods to solving my problem such as using http, and if so, where can I find more information about this?

Thanks!

© Stack Overflow or respective owner

Related posts about java

Related posts about sockets