Win a copy of Think Java: How to Think Like a Computer Scientist this week in the Java in General forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

A general question

 
Maysam Sorkhabi
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 42
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic