+2007-01-26 Dick Porter <dick@ximian.com>
+
+ * Socket.cs: There's no point checking the SO_ERROR status of a
+ socket after poll() or select() if we already know that connected
+ == true.
+
2007-01-24 Dick Porter <dick@ximian.com>
* IOControlCode.cs:
}
if (!result.Sock.Blocking) {
- result.Sock.Poll (-1, SelectMode.SelectWrite);
- int success = (int)result.Sock.GetSocketOption (SocketOptionLevel.Socket, SocketOptionName.Error);
+ int success;
+ result.Sock.Poll (-1, SelectMode.SelectWrite, out success);
if (success == 0) {
result.Sock.connected = true;
result.Complete ();
}
if (currentList != null) {
- if (currentList == checkWrite) {
+ if (currentList == checkWrite &&
+ sock.connected == false) {
if ((int)sock.GetSocketOption (SocketOptionLevel.Socket, SocketOptionName.Error) == 0) {
sock.connected = true;
}
if (error != 0)
throw new SocketException (error);
- if (mode == SelectMode.SelectWrite && result == true) {
+ if (mode == SelectMode.SelectWrite &&
+ result == true &&
+ connected == false) {
/* Update the connected state; for
* non-blocking Connect()s this is
* when we can find out that the
+2007-01-26 Dick Porter <dick@ximian.com>
+
+ * SocketTest.cs: New test for SO_ERROR reading, returning the same
+ value over and over.
+
2007-01-25 Ilya Kharmatsky <ilyak -at- mainsoft.com>
* UdbClientTest.cs: Added Ignore attribute for entire test fixture
s.Shutdown (0);
}
+ static ManualResetEvent SocketError_event = new ManualResetEvent (false);
+
+ private static void SocketError_callback (IAsyncResult ar)
+ {
+ Socket sock = (Socket)ar.AsyncState;
+
+ if(sock.Connected) {
+ sock.EndConnect (ar);
+ }
+
+ SocketError_event.Set ();
+ }
+
+ [Test]
+ public void SocketError ()
+ {
+ Socket sock = new Socket (AddressFamily.InterNetwork,
+ SocketType.Stream,
+ ProtocolType.Tcp);
+ IPEndPoint ep = new IPEndPoint (IPAddress.Loopback,
+ BogusPort);
+
+ SocketError_event.Reset ();
+
+ sock.Blocking = false;
+ sock.BeginConnect (ep, SocketError_callback,
+ sock);
+
+ if (SocketError_event.WaitOne (2000, false) == false) {
+ Assert.Fail ("SocketError wait timed out");
+ }
+
+ Assertion.AssertEquals ("SocketError #1", false,
+ sock.Connected);
+
+ int error;
+
+ error = (int)sock.GetSocketOption (SocketOptionLevel.Socket, SocketOptionName.Error);
+ Assertion.AssertEquals ("SocketError #2", 10061,
+ error);
+
+ error = (int)sock.GetSocketOption (SocketOptionLevel.Socket, SocketOptionName.Error);
+ Assertion.AssertEquals ("SocketError #3", 10061,
+ error);
+
+ sock.Close ();
+ }
+
+
#if NET_2_0
[Test]
public void SocketInformationCtor ()