Click here to Skip to main content
15,888,219 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
In java, there is "AsynchronousSocketChannel" class. We can use it to accept a socket which is not blocking. I know there is a method named "Socket.BeginConnect". But I don't know if it is a non-blocking method. Or it is just a blocking method in another thread.
Posted

1 solution

The documentation Socket.BeginConnect Method (EndPoint, AsyncCallback, Object) (System.Net.Sockets)[^] says:
When your application calls BeginConnect, the system will use a separate thread to execute the specified callback method, and will block on EndConnect until the Socket connects successfully or throws an exception.

Which means it works as I would expect: it starts a separate thread to perform the blocking operation.
 
Share this answer
 
Comments
Water1988 30-Jan-16 11:45am    
So, It's not like aio in java. Because as I know aio doesn't need to start another blocked thread.
How about ConnectAsnyc method, is it a non-blocking method.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900