Windows Sokets (tcpclient) problem.

M

mulham.haffar

hi..
im writing an application that uses tcpclient/tcplistener to send file
via network, what im doing is dividing the file into small parts each
part equals the buffer size (8192) and send the parts sequentialy.
the problem is :
the listener is detecting a stream to be read once every two times the
sender sends a stream.
I triend to fix it by sending one byte {0} before each send function
and it worked because the listener ignores the first send (which is the
0 byte) then detects the next send which is the acutaul data, but i
realized that the 0 byte is still in the buffer so its attached the
next stream read.
any help? any idea is appreciated .. thank you in advance.
 
G

Goran Sliskovic

hi..
im writing an application that uses tcpclient/tcplistener to send file
via network, what im doing is dividing the file into small parts each
part equals the buffer size (8192) and send the parts sequentialy.
the problem is :
the listener is detecting a stream to be read once every two times the
sender sends a stream.
I triend to fix it by sending one byte {0} before each send function
and it worked because the listener ignores the first send (which is the
0 byte) then detects the next send which is the acutaul data, but i
realized that the 0 byte is still in the buffer so its attached the
next stream read.
any help? any idea is appreciated .. thank you in advance.
....

It's very unlikly that you actually lose bytes in transfer. Keep in mind
that receiver does not receive data in blocks as it was sent. You can get
less then a block you sent in single read or bytes can be buffered by OS and
you can receive more than single block.

Regards,
Goran
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top