aspose file tools*
The moose likes Sockets and Internet Protocols and the fly likes A general question Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Sockets and Internet Protocols
Bookmark "A general question" Watch "A general question" New topic
Author

A general question

Maysam Sorkhabi
Greenhorn

Joined: Jul 13, 2004
Posts: 23
Hello all,
I have developed a chat client and now I'd like to add file transfer capability to it. Here are some of the thoughts I've had with respect to I should go about implementing this.

1. Do I need additional sockets ONLY for the sake of transfering files?(i.e. reading/writing to an extra socket)

2. Do I need additional threads to handle this task? If so, should I construct a new socket or I'd be better off with the URL/URLConnection classes?

Thank you very much for you're help.
Catalin Merfu
Ranch Hand

Joined: May 26, 2004
Posts: 42
IMHO it would be better if youcould reuse the chat socket for file transfer.
If it's not possible open a new socket for file transfer and close it immediately. The proble with the second socket is that your application will consume another socket on the client side and limit the number of clients that can be serviced simultaneously.

If you decide to use a second socket most likely you'll want to spawn a second thread. If not does your network layer allow you to send the file and chat at the same time?

I answered another chat application topic today:
http://www.coderanch.com/t/209536/java/java/create-chat-RMI


Catalin Merfu<br /><a href="http://www.accendia.com" target="_blank" rel="nofollow">High Performance Java Networking</a>
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: A general question