SocketOption ReceiveTimeOut

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • eran otzar
    New Member
    • Jan 2011
    • 13

    SocketOption ReceiveTimeOut

    now lets take a secnario where we use a locking socket receive and the packet is 5000 bytes with receivetimeout set to one second

    s.SetSocketOpti on (SocketOptionLe vel.Socket, SocketOptionNam e.ReceiveTimeou t, 1000);

    int bytes_recevied = 0 ; byte [] ReceiveBuffer = new byte[8192] ;

    try { bytes_received = s.Receive(Recev ieBuffer) ; } catch(SocketExc eption e) { if( e.ErrorCode == 10060) { Array.Clear(Rec eiveBuffer,0,Re ceiveBuffer.Len gth); } }

    now our secnario dictates that 4000 bytes have gone threw alreadys,the socket is still blocking and some error accured on the receiving end , now on the receiving end we would handly dispose of the 4000 bytes by catching the socket ecxecption

    is there any guaranty that the socket on the sending end wont thows 1000 bytes that remain does the sending socket know to truncate them if he wasent disconnected when we attempt to receive again wont they be the first bytes we receive ?

    what im asking is : a) does tcp have some mecanisem that tells the socket to dispose of the rest of them message ? is there a socket flag that we could send or receive with that tells the buffers to dispose of the rest of the message ?
Working...