tags:

views:

23

answers:

1

I try to send file to chatFriend,I send a sendFileInformation include which file I select to send to Server which support we chat before I send file .Then Server send it to chatFriend ,when chatFriend get it,he will open a new ServerSocket and response to me,then send the file,chatFriend save the file.when transfer,he can give up. At the same time,if another person also want to send him file by his opening ServerSocket,he can also save the file. How to make it true? could I new a ServerScoket using the same port if anyone send me file at the same time. which Stream to use when send file,what's the problem if I use DataoutputStream and DateInputStream but the fiel receiver got is not right? Can give me examples?Thank you.

+1  A: 

Hopefully, i understood your question...

No, you cannot use the same port for 2 (or more) simultaneous connections (for TCP anyway).

Please look into "Threads". You're trying to build a Multi-Threaded Server.

Each File Transfer should happen on a different port. So each FileTransfer should have its own ServerSocket.

st0le