Jinith
Jinith

Reputation: 1007

Java Sockets Client-Server application

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?

Upvotes: 2

Views: 1145

Answers (2)

jeremywho
jeremywho

Reputation: 309

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?

Upvotes: 0

clamchoda
clamchoda

Reputation: 4981

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

Upvotes: 2

Related Questions