Programming Tools
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
 
Go Back   Dev Articles Community ForumsProgrammingProgramming Tools

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Display Modes
 
Unread Dev Articles Community Forums Sponsor:
  #1  
Old August 28th, 2002, 06:06 PM
ssruprai ssruprai is offline
Junior Member
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Apr 2002
Posts: 12 ssruprai User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Send a message via ICQ to ssruprai
tranfer files using socket in a chat application

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?

Reply With Quote
  #2  
Old August 29th, 2002, 09:00 AM
FrankieShakes FrankieShakes is offline
Frank The Tank!
Dev Articles Beginner (1000 - 1499 posts)
 
Join Date: Jun 2002
Location: Toronto, Canada
Posts: 1,246 FrankieShakes User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 8
Send a message via ICQ to FrankieShakes Send a message via MSN to FrankieShakes
Would it not be possible if you were to create another socket object? Rather than using socket.getOutputStream() / getInputStream(), create another object (ie: socketFiles) and try using the getInputStream() and getOutputStream() with the newly created object.
__________________
____________________________________________
Developer Shed Weekly Writer | DevArticles Forum Moderator
Build Your Own KlipFolio Klip With PHP
FrankManno.com - Under Construction
Design Interactive Group - Under Construction

Reply With Quote
  #3  
Old August 30th, 2002, 04:09 PM
ssruprai ssruprai is offline
Junior Member
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Apr 2002
Posts: 12 ssruprai User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Send a message via ICQ to ssruprai
"create another object (ie: socketFiles) and try using the getInputStream() and getOutputStream() with the newly created object."

So according to you if a client wants to send a file to other person then it should open another socket on same server port. Accroding to this:

1. how server knows it is not a new chat client but a request to transfer file from one already connected user to another alredy connected user. Because when accepting socket connection server cannot determine if it is new connection from already connected user. Or I have to modify my application completely to send a specific message after client connects that this socket connection is for sending file.

2. Even if I somehow determine that an already connected client (sender of file) wants to send a file to other client then how does server opens another socket connection to another client computer(receiver of file). In this way client also has to act as a server and listen to a specific port and allow server to connect to it. I think it is not very efficient.

What do you think?

Reply With Quote
  #4  
Old September 1st, 2002, 09:54 AM
FrankieShakes FrankieShakes is offline
Frank The Tank!
Dev Articles Beginner (1000 - 1499 posts)
 
Join Date: Jun 2002
Location: Toronto, Canada
Posts: 1,246 FrankieShakes User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 8
Send a message via ICQ to FrankieShakes Send a message via MSN to FrankieShakes
Quote:
Originally posted by ssruprai
So according to you if a client wants to send a file to other person then it should open another socket on same server port. Accroding to this:

1. how server knows it is not a new chat client but a request to transfer file from one already connected user to another alredy connected user. Because when accepting socket connection server cannot determine if it is new connection from already connected user. Or I have to modify my application completely to send a specific message after client connects that this socket connection is for sending file.

2. Even if I somehow determine that an already connected client (sender of file) wants to send a file to other client then how does server opens another socket connection to another client computer(receiver of file). In this way client also has to act as a server and listen to a specific port and allow server to connect to it. I think it is not very efficient.

What do you think?


I'm gonna double-check my reference book on this... It's been a while for me... But if I'm not mistaken, you would have to use another specific port for file transfers...

Essentially, what you're doing is building a server/client for both systems... So it's a P2P application. Each user acts as a server and a client...

Have you had any progress?

Reply With Quote
  #5  
Old September 1st, 2002, 01:56 PM
ssruprai ssruprai is offline
Junior Member
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Apr 2002
Posts: 12 ssruprai User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Send a message via ICQ to ssruprai
Thank you.

I was thinking the way where client has to act as a client and server too.

Reply With Quote
Reply

Viewing: Dev Articles Community ForumsProgrammingProgramming Tools > tranfer files using socket in a chat application


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 3 hosted by Hostway
Stay green...Green IT