Here is ToString() of the exception object raised:
{System.Net.Sockets.SocketException}
[System.Net.Sockets.SocketException]: {System.Net.Sockets.SocketException}
InnerException: Nothing
Message: "An existing connection was forcibly closed by the remote host"
------------------------------------------------------------
Here is the code:
Dim myRequest As System.Net.HttpWebRequest
Dim myResponse As System.Net.WebResponse
Dim myProxy As New System.Net.WebProxy
Dim bPostData() As Byte
Dim sPost As String
Dim Stream1 As System.IO.Stream
Dim newUri As System.Uri
sPost = StrDup(25000, "X")
Cursor.Current = Cursors.WaitCursor
myRequest = System.Net.WebRequest.Create("
http://server.com/file.php")
myRequest.Timeout = 30000
myProxy = New System.Net.WebProxy
newUri = New Uri("
http://192.168.2.36:4480")
' Associate the new Uri object to the myProxy object.
myProxy.Address = newUri
myProxy.Credentials = New System.Net.NetworkCredential("admin", "admin")
myRequest.Proxy = myProxy
myRequest.Method = "POST"
myRequest.ContentType = "application/x-www-form-urlencoded"
' Encode the data
bPostData = System.Text.Encoding.UTF8.GetBytes(sPost)
myRequest.ContentLength = bPostData.Length
' must buffer request for authentication
myRequest.AllowWriteStreamBuffering = True
Try
' Write encoded data into request stream
Stream1 = myRequest.GetRequestStream()
Stream1.Write(bPostData, 0, bPostData.Length)