Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

tranfer files using socket in a chat application

Status
Not open for further replies.

ssruprai

Programmer
Apr 24, 2002
16
IN
Hello,
I have created a simple multithreaded chat application using Java sockets. When a new client connects a new server thread is created to handle communication with that client.

I also want to allow clients to transfer files from one computer to another.

I think there cannot be direct connection between two clients when using applets.
So server has to receive the file from one client and send it to other client.

1. But even then how connection between two clients can be opened.

Problem is using socket.getOutputStream() and socket.getInputStream() only one output/input stream is created, so file contents cannot be transferred using that input/output stream because that stream is used to receive and send chat messages and I want clients to continue sending and receiving messages when file is being transferred.

2. Can a server connect to client's computer to some other port (for sending file) if that client is already connected to the server for sending and receiving messages i.e if there is already a socket connection between client and server.

3. Can file be transferred by getting second input/output stream using socket.getInputStream() and socket.getOutputStream() again?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top