Mike Warren
Mike Warren

Reputation: 3866

Sending the IP address via two-way client-server interaction in Java

I am trying to write a Java program that will send the data from a beta-tester's computer to mine. I used serialization to save the data to their computer, and now I am needing to fetch it and store it in the database. For this, I will need their IP address. (I will also be needing it for generating a userID for them.) It is because, in doing all this, I would be the client (sending serialization file via sockets in java) and they would be the server. Of course, in client-server interaction, I would need to know their IP address. To circumvent that, I have decided to have them be the client (and request MY IP address, which is known, or some other information), and then I, as server, would request their IP address. When I have their IP address, I can request the information from them and store it onto the database.

Any suggestions as to how to go about this?

Upvotes: 0

Views: 1370

Answers (1)

Femaref
Femaref

Reputation: 61437

You just need a program that will listen for connections on a certain port, and handle the data that is sent to it. The program that will sent data will have to know either a hostname or an ip address to initiate a connection to that program.

The program listening for connections is the server, the program initiating the connection is the client. Nothing to do with who sends data.

Upvotes: 1

Related Questions