HighTechTalks DotNet Forums  

Windows Sockets (TCPClient) problem.

Dotnet Academic General Discussions microsoft.public.dotnet.academic


Discuss Windows Sockets (TCPClient) problem. in the Dotnet Academic General Discussions forum.



Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old   
AT
 
Posts: n/a

Default Windows Sockets (TCPClient) problem. - 11-19-2005 , 07:22 AM






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.


Reply With Quote
  #2  
Old   
Vadym Stetsyak
 
Posts: n/a

Default Re: Windows Sockets (TCPClient) problem. - 11-29-2005 , 04:33 PM






That is not a problem. TCP guarantees that data will be sent in the right
order ( the order being sent ) & that it will reach the destination.

What TCP doesn't guarantee is the size of data. E.g. if you sent 8k of data
listener may call Receive multiple times, this depends on network
conditions, sliding window size etc ( for details look into RFC793 for the
tcp protocol description)

What you can do to solve the trouble is to read (Receive) data until you
will receive your 8192 bytes of data.

--
Vadym Stetsyak aka Vadmyst
http://vadmyst.blogspot.com

<mulham.haffar (AT) gmail (DOT) com> wrote

Quote:
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.




Reply With Quote
  #3  
Old   
Sinu
 
Posts: n/a

Default RE: Windows Sockets (TCPClient) problem. - 01-30-2006 , 09:46 AM



Hi,
You need to loop into the receive function and trust me the "IsAvailable"
Function does not work. So you need to loop atleast 10 times to get the
actual data and when you finally dont get any data then you can quit.
I have written many C# client/server apps, but the only solution I got was
to loop till I found the Filesize which I send with the first request. There
is no other way!
--
Shrinivas Reddy.
Systems Analyst
Satyam Computer Services Ltd.


"mulham.haffar (AT) gmail (DOT) com" wrote:

Quote:
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.



Reply With Quote
Reply




Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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



Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.