A
Assaf Shemesh
Hi,
I'm having a problem with asynchronous HttpWebRequest. It's a simple
http client-server. For most of my users it works fine. However, some
of them get the exception:
System.Net.WebException: Unable to connect to the remote server --->
System.Net.Sockets.SocketException: The attempted operation is not
supported for the type of object referenced
at System.Net.Sockets.Socket.get_ConnectEx()
at System.Net.Sockets.Socket.BeginConnectEx(EndPoint remoteEP,
Boolean flowContext, AsyncCallback callback, Object state)
at System.Net.Sockets.Socket.UnsafeBeginConnect(EndPoint remoteEP,
AsyncCallback callback, Object state)
at System.Net.ServicePoint.ConnectSocketInternal(Boolean
connectFailure, Socket s4, Socket s6, Socket& socket, IPAddress&
address, ConnectSocketState state, IAsyncResult asyncResult, Int32
timeout, Exception& exception)
--- End of inner exception stack trace ---
at System.Net.HttpWebRequest.EndGetResponse(IAsyncResult
asyncResult)
My code is:
Uri url = new Uri(getURI());
m_request = (HttpWebRequest)WebRequest.Create(url);
m_request.Credentials = CredentialCache.DefaultCredentials;
m_request.UserAgent = getUserAgent();
m_request.BeginGetResponse(new AsyncCallback(ProcessResponse), null);
and then:
private void ProcessResponse(IAsyncResult asynchronousResult) {
HttpWebResponse response =
(HttpWebResponse)m_request.EndGetResponse(asynchronousResult);
Stream stream = response.GetResponseStream();
....
}
This is so weird.
Any ideas ?
Thanks!
I'm having a problem with asynchronous HttpWebRequest. It's a simple
http client-server. For most of my users it works fine. However, some
of them get the exception:
System.Net.WebException: Unable to connect to the remote server --->
System.Net.Sockets.SocketException: The attempted operation is not
supported for the type of object referenced
at System.Net.Sockets.Socket.get_ConnectEx()
at System.Net.Sockets.Socket.BeginConnectEx(EndPoint remoteEP,
Boolean flowContext, AsyncCallback callback, Object state)
at System.Net.Sockets.Socket.UnsafeBeginConnect(EndPoint remoteEP,
AsyncCallback callback, Object state)
at System.Net.ServicePoint.ConnectSocketInternal(Boolean
connectFailure, Socket s4, Socket s6, Socket& socket, IPAddress&
address, ConnectSocketState state, IAsyncResult asyncResult, Int32
timeout, Exception& exception)
--- End of inner exception stack trace ---
at System.Net.HttpWebRequest.EndGetResponse(IAsyncResult
asyncResult)
My code is:
Uri url = new Uri(getURI());
m_request = (HttpWebRequest)WebRequest.Create(url);
m_request.Credentials = CredentialCache.DefaultCredentials;
m_request.UserAgent = getUserAgent();
m_request.BeginGetResponse(new AsyncCallback(ProcessResponse), null);
and then:
private void ProcessResponse(IAsyncResult asynchronousResult) {
HttpWebResponse response =
(HttpWebResponse)m_request.EndGetResponse(asynchronousResult);
Stream stream = response.GetResponseStream();
....
}
This is so weird.
Any ideas ?
Thanks!