Socket.Select() does not block???

  • Thread starter Thread starter Boris
  • Start date Start date
B

Boris

I have a strange problem as Socket.Select() doesn't block when I call it in
C#. To be sure that there is no error in my code I went to
http://msdn.microsoft.com/library/d...lrfsystemnetsocketssocketclassselecttopic.asp
and copied the sample C# code into VS 2004. When I run the sample code
Socket.Select() does not block?! It returns immediately with an empty IList.

Can anyone please compile and run the following code? I don't understand why
Socket.Select() does not block on my machine? Is Socket.Select() broken or
my .NET framework?

----------------------------
using System;
using System.Collections;
using System.Net;
using System.Net.Sockets;

class SelectTest
{
static void Main(string[] args)
{
Socket mySocket = new Socket(AddressFamily.InterNetwork,
SocketType.Stream, ProtocolType.Tcp);
mySocket.Bind(new IPEndPoint(IPAddress.Any, 12345));
mySocket.Listen(1);

ArrayList list = new ArrayList();
list.Add(mySocket);

Socket.Select(list, null, null, 1000000);
}
}
 
Boris said:
I have a strange problem as Socket.Select() doesn't block when I call it in
C#. To be sure that there is no error in my code I went to
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpre
f/html/frlrfsystemnetsocketssocketclassselecttopic.asp
and copied the sample C# code into VS 2004. When I run the sample code
Socket.Select() does not block?! It returns immediately with an empty IList.

Can anyone please compile and run the following code? I don't understand why
Socket.Select() does not block on my machine? Is Socket.Select() broken or
my .NET framework?

When you say it returns "immediately", how immediately do you mean? On
my box the same program blocks for a second before returning - exactly
as I'd expect with a wait time of 1000000 microseconds.
 
Jon said:
[...]
When you say it returns "immediately", how immediately do you mean? On
my box the same program blocks for a second before returning - exactly
as I'd expect with a wait time of 1000000 microseconds.

I guess it would be a good idea to go to bed earlier and not to program at 2
am ... Thanks for your help and sorry for the confusion but I read
milliseconds and not microseconds in the documentation ... oh well ...

Boris
 
Back
Top