+2009-05-22 Sebastien Pouliot <sebastien@ximian.com>
+
+ * Socket_2_1.cs: Do not throw a SecurityException if the security
+ policy check fails in NET_2_1 but set the SocketError to AccessDenied
+ ensure the EndPoint has a valid policy before connecting.
+ * SocketAsyncEventArgs.cs: Don't recurse endlessly in SendCallback
+ and ReceiveCallback if the socket is not connected. Check for
+ AccessDenied in ConnectCallback (needed for the security policy
+ check in NET_2_1).
+
2009-05-14 Sebastien Pouliot <sebastien@ximian.com>
* Socket_2_1.cs: Add ConnectAsync support for NET_2_1 which will
SocketError = SocketError.Success;
LastOperation = SocketAsyncOperation.Receive;
SocketError error = SocketError.Success;
+
+ if (!curSocket.Connected) {
+ SocketError = SocketError.NotConnected;
+ return;
+ }
try {
// FIXME: this does not support using BufferList
void ConnectCallback ()
{
- SocketError = SocketError.Success;
LastOperation = SocketAsyncOperation.Connect;
+#if NET_2_1
+ if (SocketError == SocketError.AccessDenied) {
+ curSocket.Connected = false;
+ OnCompleted (this);
+ return;
+ }
+#endif
+ SocketError = SocketError.Success;
SocketError error = SocketError.Success;
try {
LastOperation = SocketAsyncOperation.Send;
SocketError error = SocketError.Success;
+ if (!curSocket.Connected) {
+ SocketError = SocketError.NotConnected;
+ return;
+ }
+
try {
if (Buffer != null) {
BytesTransferred = curSocket.Send_nochecks (Buffer, Offset, Count, SocketFlags.None, out error);
public Socket(AddressFamily family, SocketType type, ProtocolType proto)
{
+#if NET_2_1
+ if (family == AddressFamily.Unspecified)
+ throw new ArgumentException ("family");
+#endif
address_family=family;
socket_type=type;
protocol_type=proto;
if (!checkPolicy)
return;
+ e.SocketError = SocketError.AccessDenied;
if (check_socket_policy == null) {
Type type = Type.GetType ("System.Windows.Browser.Net.CrossDomainPolicyManager, System.Windows.Browser, Version=2.0.5.0, Culture=Neutral, PublicKeyToken=7cec85d7bea7798e");
check_socket_policy = type.GetMethod ("CheckEndPoint");
if (check_socket_policy == null)
throw new SecurityException ();
}
- if (!(bool) check_socket_policy.Invoke (null, new object [1] { e.RemoteEndPoint }))
- throw new SecurityException ();
+ if ((bool) check_socket_policy.Invoke (null, new object [1] { e.RemoteEndPoint }))
+ e.SocketError = SocketError.Success;
}
// only _directly_ used (with false) to download the socket policy