开发者

ServicePoint is not unique to a local IPEndpoint

I have an application where I need to send 2 web requests to the same Url, but from different source IPEndpoints.

This can be done simple enough with the first connection by doing something like:

Dim myWebRequest As Net.HttpWebRequest = Net.WebRequest.Create(MyUrl)
myWebRequest.ServicePoint.BindIPEndPointDelegate = MyBindIPEndPointFunction

The delegate function MyBindIPEndPointFunction is called and I give it the correct IPEndpoint, everything works fine.

However on the second request, because there is already a ServicePoint for this Url, the delegate function MyBindIPEndPointFunction is not called so I do not have a way of telling the second web request to bind to a different IPEndpoint.

Because the web requests are SSL it isn't easy to just use a Net.TcpClient object instead as I'd have to handle the SSL.

Ideally I'd like way of forcing HttpWebRequest to just create a normal connection and close it once it's finished with it - without employing any ServicePoint - is this possible? I'd also like this to all be thread safe and non-blocking so I can fire开发者_C百科 off requests in many threads (which at the moment would all use the same ServicePoint).

Thanks.


could always set your endpoints in code and just create two with different variable names and the same url

  Private binding1 As New BasicHttpBinding(BasicHttpSecurityMode.TransportCredentialOnly)
  Private binding2 As New BasicHttpBinding(BasicHttpSecurityMode.TransportCredentialOnly)
Private WithEvents _Misc1 As Service_Misc.Misc_CallsClient = New Misc_CallsClient(binding1, New EndpointAddress("http://localhost:61928/Misc_Calls.svc"))
Private WithEvents _Misc2 As Service_Misc.Misc_CallsClient = New Misc_CallsClient(binding2, New EndpointAddress("http://localhost:61928/Misc_Calls.svc"))
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜