bool block,
out int error);
#endif
-#if !NET_2_1 || MONOTOUCH
+
public bool Blocking {
get {
return(blocking);
blocking=value;
}
}
-#endif
+
public bool Connected {
get { return connected; }
internal set { connected = value; }
void Linger (IntPtr handle)
{
- if (linger_timeout <= 0)
+ if (!connected || linger_timeout <= 0)
return;
// We don't want to receive any more data
return;
disposed = true;
+ bool was_connected = connected;
connected = false;
if ((int) socket != -1) {
int error;
blocking_thread = null;
}
- Linger (x);
+ if (was_connected)
+ Linger (x);
//DateTime start = DateTime.UtcNow;
Close_internal (x, out error);
//Console.WriteLine ("Time spent in Close_internal: {0}ms", (DateTime.UtcNow - start).TotalMilliseconds);
if (ep.Address.Equals (IPAddress.Any) || ep.Address.Equals (IPAddress.IPv6Any))
throw new SocketException ((int) SocketError.AddressNotAvailable);
-#if NET_2_1 && !MONOTOUCH
+#if MOONLIGHT
if (protocol_type != ProtocolType.Tcp)
throw new SocketException ((int) SocketError.AccessDenied);
#elif NET_2_0
[MethodImplAttribute(MethodImplOptions.InternalCall)]
extern static bool Poll_internal (IntPtr socket, SelectMode mode, int timeout, out int error);
-#if !NET_2_1 || MONOTOUCH
/* This overload is needed as the async Connect method
* also needs to check the socket error status, but
* getsockopt(..., SO_ERROR) clears the error.
return result;
}
-#endif
+
[MethodImplAttribute(MethodImplOptions.InternalCall)]
private extern static int Receive_internal(IntPtr sock,
byte[] buffer,
if (disposed && closed)
throw new ObjectDisposedException (GetType ().ToString ());
+ if (!connected)
+ throw new SocketException (10057); // Not connected
+
int error;
Shutdown_internal (socket, how, out error);
-
if (error != 0)
throw new SocketException (error);
}
#endif
}
-#if NET_2_1 && !MONOTOUCH
+#if MOONLIGHT
static void CheckConnect (SocketAsyncEventArgs e)
{
// NO check is made whether e != null in MS.NET (NRE is thrown in such case)