0

Hi,

So i got pretty far whit Java i covered basic operation, GUI w/e MVC design etc. It been a fun year learning Java. Now i want to make an application for communication between two
points similar to a TFTP Server/Client.

So this is how i visioned this to go: I would have 2 classes where:
~ 1 would serve as Server
~ 1 would serve as Client

Server class would be running constantly and would contain the ip of the pc that
contains the class file and would listen and wait until Client class would be started. Once
Client class would be started Server would transfer the file from his pc to client pc.

So far i dont know yet what Java tools come in to play here what should i look at are there any tutorials or similar.

Thanks in advance.

2
Contributors
1
Reply
2
Views
5 Years
Discussion Span
Last Post by JamesCherrill
0

The two key classes you will need are ServerSocket and Socket (short for "client socket").
You create a ServerSocket on your server. It listens for incoming requests on a chosen port.
You create a Socket at the client that connects to the server. The ServerSocket accepts the connection and gives you another Socket that represents the server end of the connection.
Now both the client and the server have their own Socket, and those two Sockets are connected. Each Socket has an input stream and an output stream. You can use those streams to send & receive data across the connection.

Hopefully that's enough info for you to know what to look for on the web.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.