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 SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

socket programming

Status
Not open for further replies.

newbie1983

Programmer
Sep 9, 2003
52
0
0
GB
I am currently writing a client/server application using sockets to transfer files. I would like a series of messages to be sent before transfering the file. However when i do this, the messages are written to the socket output stream (when you invoke ClientSocket.getOutputStream()); ) and are written to the file to be transferred. Is there any way to "clear" the Socket stream? i tried assigning "null" but it seems to fall over.

Any ideas much appreciated!

Regards

newbie1983
 
I suspect you're writing to the file because your Socket OutputStream is linked to your FileInputStream.
Post your code and let us take a look at it
 
You should also remember that sockets don't know anything about messages -- they just send bytes. And... If you send 1000 bytes, it's possible for it to arrive in two separate packets of 500 bytes each.

Chip H.


____________________________________________________________________
If you want to get the best response to a question, please read FAQ222-2244 first
 
The Socket stream is "cleared" when the server sends data AND the client fully reads that data.

--------------------------------------------------
Free Database Connection Pooling Software
 
Thanks for your replies! I kind of figured it out just needed to create the streams again after use

Regards

HP
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top