I think I got it...
SocketAddress local_isa = null;
SocketAddress remote_isa = new InetSocketAddress(host, port);
try
{
local_isa = new InetSocketAddress(InetAddress.getLocalHost(), 0);
}
catch (UnknownHostException e)
{
e.printStackTrace();
}
sessionRequest = ioReactor.connect(remote_isa, local_isa, this,
new SessionRequestCallback()
{
public void cancelled(SessionRequest request) {
System.out.println("cancelled...");
}
public void completed(SessionRequest request) {
System.out.println("completed... LocalPort:" +
request.getSession().getLocalAddress());
}
public void failed(SessionRequest request) {
connectionFailed();
}
public void timeout(SessionRequest request) {
System.out.println("timeout...");
}
}
};
tjmcsorley wrote:
>
> I'm using the NHTTPClient.java example code to build a test harness to
> drive a considerable load against a Web Server. Some of the interactions
> are exhibiting errors when the Web Server is stressed with many
> simultaneous connections... How can I extract the local TCP port from a
> connection so that I can correlate this with a network capture and then
> isolate a particular connection for analysis?
>
> I've tried using the SessionRequest.getLocalAddress() method, however it
> is always null...
>
> Reading through the GuidedTourOfHttpCore wiki page I see that somehow I
> should be able to use the HttpInetConnection interface to possibly
> accomplish this.
>
> But I don't see how to tie that into the NHTTPClient.java sample code.
> Could you please provide an example on how to do this?
>
> Thanks!
>
> - tom
>
--
View this message in context:
http://www.nabble.com/Example-code-NHTTPClient.java---how-to-determine-local-TCP-port-for-a-connection-tf4822837.html#a13798335
Sent from the HttpComponents-Dev mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]