Re: .NET Socket
- From: Cool Guy <coolguy@xxxxxxx>
- Date: Mon, 25 Jul 2005 11:55:46 +0100
Rahul Anand <RahulAnand@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote:
> <CODE>
>
> Byte[] bytesReceived = new Byte[256];
> do
> {
> bytes = s.Receive(bytesReceived);
> strReceived += Encoding.ASCII.GetString(bytesReceived, 0, bytes);
> }
> while (bytes > 0);
>
> </CODE>
>
> But later I noticed that if in last iteration the bytes come to be less than
> 256 i.e. when I have received all data the next receive call causes the
> execution to block as receive has nothing to receive.
So the problem you're trying to solve is preventing a call to
Socket.Receive from blocking indefinitely?
If so, you're approaching the problem incorrectly. You should use the
above code in a worker thread, *allowing* it to block indefinitely. You
can call Socket.Shutdown in another thread to interrupt that blocking call.
.
- Follow-Ups:
- Re: .NET Socket
- From: Rahul Anand
- Re: .NET Socket
- References:
- .NET Socket
- From: Rahul Anand
- .NET Socket
- Prev by Date: C# .NET Contract Work Required
- Next by Date: Re: Data Layer architecture
- Previous by thread: .NET Socket
- Next by thread: Re: .NET Socket
- Index(es):
Relevant Pages
|