2

I Am trying to code a java program with sockets in which i have 3 system(1 server and two clients) both the clients connect to the server at the same port.Its a file transfer program.

Now my requirement is that both the connection would remain active throughout and as soon as client1 writes to its socket connection on the server the server relays that data to the socket between server and client2.

How can i achieve this?

2 Answers 2

2

There are TONES of client/server chat examples out there for many different languages. All of them are fairly similar.

Try Google Java client/server chat tutorial. Here's one if you couldn't find an example.

http://inetjava.sourceforge.net/lectures/part1_sockets/InetJava-1.9-Chat-Client-Server-Example.html

Sign up to request clarification or add additional context in comments.

1 Comment

Hi Chris thanks for the reply.Actually i need to create a file transfer application.Sending file in byte array of size 1024.
0

Jinith: transferring a file is not that different from sending text over a socket. Do you have any specific requirements for how the clients know to get data? Are you familiar with blocking/nonblocking/asynch sockets? Comfortable using threads?

2 Comments

Am a beginner to sockets.My requirement is something like client 1 writes a byte array to its socket connection with server and the server writes the byte array to its socket connection to client 2.I need to keep file transfer from client 1 to server blocked till client 2 is not connected to server.Once Client 2 is also connected file transfer should begin.
Start with just getting a client and server running and connecting, then work on sending a file from client to server, then try to add the multi-client support.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.