Local Ports SocketEndPoints and Jetty6 - specifying port 0

classic Classic list List threaded Threaded
8 messages Options
Reply | Threaded
Open this post in threaded view
|

Local Ports SocketEndPoints and Jetty6 - specifying port 0

Millington, Steve
I am trying to integrate Jetty6 as part of my unit testing suite. I will
be wanting to connect to my jetty server using HTTP, and therefore am
using one of the various connectors in Jetty6.

When I specify the connector, I specify a port upon which to listen. For
my test suite I want any number of these tests to be run at any time by
any users (it is a unix box after all!). For traditional ServerSocket
stuff, I can specify the port as zero, and then find out the actual port
build listened to by using the getLocalPort() method of ServerSocket.
What I want is to be able to do the same with Jetty.

My question then - can I get hold of the information about which port a
connector is actually listening on? It seems that the SocketEndPoint has
such a thing, but how do I get hold of the SocketEndPoint for a
particular connector?

Thanks

Steve

--

Visit our website at www.roke.co.uk

Roke Manor Research Ltd, Roke Manor, Romsey, Hampshire SO51 0ZN, UK.

The information contained in this e-mail and any attachments is proprietary to
Roke Manor Research Ltd and must not be passed to any third party without
permission. This communication is for information only and shall not create or
change any contractual relationship.



-------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc. Do you grep through log files
for problems?  Stop!  Download the new AJAX search engine that makes
searching your log files as easy as surfing the  web.  DOWNLOAD SPLUNK!
<a href="http://sel.as-us.falkag.net/sel?cmd=lnk&kid3432&bid#0486&dat1642">http://sel.as-us.falkag.net/sel?cmd=lnk&kid3432&bid#0486&dat1642
_______________________________________________
Jetty-support mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/jetty-support
Reply | Threaded
Open this post in threaded view
|

Re: Local Ports SocketEndPoints and Jetty6 - specifying port 0

Chris Haynes
On Jetty <= 5...
Extend SocketListener and supply your own inplementation of customizeRequest()

This is called with the HttpConnection as a parameter.

Call getRemotePort() on that connection.

Enjoy!

I don't know if jetty 6 uses the same architecture in this area.

Chris Haynes


----- Original Message -----
From: "Millington, Steve" <[hidden email]>
To: <[hidden email]>
Sent: Wednesday, February 15, 2006 11:23 AM
Subject: [Jetty-support] Local Ports SocketEndPoints and Jetty6 - specifying
port 0


I am trying to integrate Jetty6 as part of my unit testing suite. I will
be wanting to connect to my jetty server using HTTP, and therefore am
using one of the various connectors in Jetty6.

When I specify the connector, I specify a port upon which to listen. For
my test suite I want any number of these tests to be run at any time by
any users (it is a unix box after all!). For traditional ServerSocket
stuff, I can specify the port as zero, and then find out the actual port
build listened to by using the getLocalPort() method of ServerSocket.
What I want is to be able to do the same with Jetty.

My question then - can I get hold of the information about which port a
connector is actually listening on? It seems that the SocketEndPoint has
such a thing, but how do I get hold of the SocketEndPoint for a
particular connector?

Thanks

Steve






-------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc. Do you grep through log files
for problems?  Stop!  Download the new AJAX search engine that makes
searching your log files as easy as surfing the  web.  DOWNLOAD SPLUNK!
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=103432&bid=230486&dat=121642
_______________________________________________
Jetty-support mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/jetty-support
Reply | Threaded
Open this post in threaded view
|

RE: Re: Local Ports SocketEndPoints and Jetty6 - specifying port 0

Millington, Steve
In reply to this post by Millington, Steve
Thanks Chris, but either I haven't understood you, or you haven't
understood me :-)

I need to do this stuff before any requests have been sent to the
server. My issue is that I want to issue requests, but I don't know what
port to send them to.

Isn't customizeRequest() all about doing things to a request after it
has been received?

Steve

-----Original Message-----
From: [hidden email]
[mailto:[hidden email]] On Behalf Of Chris
Haynes
Sent: 15 February 2006 13:17
To: [hidden email]
Subject: Re: [Jetty-support] Local Ports SocketEndPoints and Jetty6 -
specifying port 0

On Jetty <= 5...
Extend SocketListener and supply your own inplementation of
customizeRequest()

This is called with the HttpConnection as a parameter.

Call getRemotePort() on that connection.

Enjoy!

I don't know if jetty 6 uses the same architecture in this area.

Chris Haynes


----- Original Message -----
From: "Millington, Steve" <[hidden email]>
To: <[hidden email]>
Sent: Wednesday, February 15, 2006 11:23 AM
Subject: [Jetty-support] Local Ports SocketEndPoints and Jetty6 -
specifying
port 0


I am trying to integrate Jetty6 as part of my unit testing suite. I will
be wanting to connect to my jetty server using HTTP, and therefore am
using one of the various connectors in Jetty6.

When I specify the connector, I specify a port upon which to listen. For
my test suite I want any number of these tests to be run at any time by
any users (it is a unix box after all!). For traditional ServerSocket
stuff, I can specify the port as zero, and then find out the actual port
build listened to by using the getLocalPort() method of ServerSocket.
What I want is to be able to do the same with Jetty.

My question then - can I get hold of the information about which port a
connector is actually listening on? It seems that the SocketEndPoint has
such a thing, but how do I get hold of the SocketEndPoint for a
particular connector?

Thanks

Steve






-------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc. Do you grep through log
files
for problems?  Stop!  Download the new AJAX search engine that makes
searching your log files as easy as surfing the  web.  DOWNLOAD SPLUNK!
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=103432&bid=230486&dat=121642
_______________________________________________
Jetty-support mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/jetty-support

--

Visit our website at www.roke.co.uk

Roke Manor Research Ltd, Roke Manor, Romsey, Hampshire SO51 0ZN, UK.

The information contained in this e-mail and any attachments is proprietary to
Roke Manor Research Ltd and must not be passed to any third party without
permission. This communication is for information only and shall not create or
change any contractual relationship.



-------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc. Do you grep through log files
for problems?  Stop!  Download the new AJAX search engine that makes
searching your log files as easy as surfing the  web.  DOWNLOAD SPLUNK!
<a href="http://sel.as-us.falkag.net/sel?cmd=lnk&kid3432&bid#0486&dat1642">http://sel.as-us.falkag.net/sel?cmd=lnk&kid3432&bid#0486&dat1642
_______________________________________________
Jetty-support mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/jetty-support
Reply | Threaded
Open this post in threaded view
|

Re: Re: Local Ports SocketEndPoints and Jetty6 - specifying port 0

Chris Haynes
Ah - even easier!

Extend SocketListener.

Wait until after start() has been called on the SocketListener, then
getInetAddrPort()
should give you the info. you need.

Chris

----- Original Message -----
From: "Millington, Steve" <[hidden email]>
To: <[hidden email]>
Sent: Wednesday, February 15, 2006 2:44 PM
Subject: RE: Re: [Jetty-support] Local Ports SocketEndPoints and Jetty6 -
specifying port 0


Thanks Chris, but either I haven't understood you, or you haven't
understood me :-)

I need to do this stuff before any requests have been sent to the
server. My issue is that I want to issue requests, but I don't know what
port to send them to.

Isn't customizeRequest() all about doing things to a request after it
has been received?

Steve

-----Original Message-----
From: [hidden email]
[mailto:[hidden email]] On Behalf Of Chris
Haynes
Sent: 15 February 2006 13:17
To: [hidden email]
Subject: Re: [Jetty-support] Local Ports SocketEndPoints and Jetty6 -
specifying port 0

On Jetty <= 5...
Extend SocketListener and supply your own inplementation of
customizeRequest()

This is called with the HttpConnection as a parameter.

Call getRemotePort() on that connection.

Enjoy!

I don't know if jetty 6 uses the same architecture in this area.

Chris Haynes


----- Original Message -----
From: "Millington, Steve" <[hidden email]>
To: <[hidden email]>
Sent: Wednesday, February 15, 2006 11:23 AM
Subject: [Jetty-support] Local Ports SocketEndPoints and Jetty6 -
specifying
port 0


I am trying to integrate Jetty6 as part of my unit testing suite. I will
be wanting to connect to my jetty server using HTTP, and therefore am
using one of the various connectors in Jetty6.

When I specify the connector, I specify a port upon which to listen. For
my test suite I want any number of these tests to be run at any time by
any users (it is a unix box after all!). For traditional ServerSocket
stuff, I can specify the port as zero, and then find out the actual port
build listened to by using the getLocalPort() method of ServerSocket.
What I want is to be able to do the same with Jetty.

My question then - can I get hold of the information about which port a
connector is actually listening on? It seems that the SocketEndPoint has
such a thing, but how do I get hold of the SocketEndPoint for a
particular connector?

Thanks

Steve







-------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc. Do you grep through log files
for problems?  Stop!  Download the new AJAX search engine that makes
searching your log files as easy as surfing the  web.  DOWNLOAD SPLUNK!
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=103432&bid=230486&dat=121642
_______________________________________________
Jetty-support mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/jetty-support
Reply | Threaded
Open this post in threaded view
|

RE: Re: Re: Local Ports SocketEndPoints and Jetty6 - specifying port 0

Millington, Steve
In reply to this post by Millington, Steve
Thanks Chris - you have at least given me the start. I have now done
what I needed in Jetty6 (or at least I have done enough).

Similar to your suggestion, I have subclassed SocketConnector to
override newServerSocket(). My override calls the superclass and stashes
the result. Once the Jetty has been started, I can call getLocalPort()
on the stashed socket to find the number I need.

I originally wanted to use the SelectChannelConnector, but I cannot se
how to do the similar thing with that. However, for my case I do not
actually care :-)

Thanks for you help

Steve

-----Original Message-----
From: [hidden email]
[mailto:[hidden email]] On Behalf Of Chris
Haynes
Sent: 15 February 2006 15:14
To: [hidden email]
Subject: Re: Re: [Jetty-support] Local Ports SocketEndPoints and Jetty6
- specifying port 0

Ah - even easier!

Extend SocketListener.

Wait until after start() has been called on the SocketListener, then
getInetAddrPort()
should give you the info. you need.

Chris

----- Original Message -----
From: "Millington, Steve" <[hidden email]>
To: <[hidden email]>
Sent: Wednesday, February 15, 2006 2:44 PM
Subject: RE: Re: [Jetty-support] Local Ports SocketEndPoints and Jetty6
-
specifying port 0


Thanks Chris, but either I haven't understood you, or you haven't
understood me :-)

I need to do this stuff before any requests have been sent to the
server. My issue is that I want to issue requests, but I don't know what
port to send them to.

Isn't customizeRequest() all about doing things to a request after it
has been received?

Steve

-----Original Message-----
From: [hidden email]
[mailto:[hidden email]] On Behalf Of Chris
Haynes
Sent: 15 February 2006 13:17
To: [hidden email]
Subject: Re: [Jetty-support] Local Ports SocketEndPoints and Jetty6 -
specifying port 0

On Jetty <= 5...
Extend SocketListener and supply your own inplementation of
customizeRequest()

This is called with the HttpConnection as a parameter.

Call getRemotePort() on that connection.

Enjoy!

I don't know if jetty 6 uses the same architecture in this area.

Chris Haynes


----- Original Message -----
From: "Millington, Steve" <[hidden email]>
To: <[hidden email]>
Sent: Wednesday, February 15, 2006 11:23 AM
Subject: [Jetty-support] Local Ports SocketEndPoints and Jetty6 -
specifying
port 0


I am trying to integrate Jetty6 as part of my unit testing suite. I will
be wanting to connect to my jetty server using HTTP, and therefore am
using one of the various connectors in Jetty6.

When I specify the connector, I specify a port upon which to listen. For
my test suite I want any number of these tests to be run at any time by
any users (it is a unix box after all!). For traditional ServerSocket
stuff, I can specify the port as zero, and then find out the actual port
build listened to by using the getLocalPort() method of ServerSocket.
What I want is to be able to do the same with Jetty.

My question then - can I get hold of the information about which port a
connector is actually listening on? It seems that the SocketEndPoint has
such a thing, but how do I get hold of the SocketEndPoint for a
particular connector?

Thanks

Steve







-------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc. Do you grep through log
files
for problems?  Stop!  Download the new AJAX search engine that makes
searching your log files as easy as surfing the  web.  DOWNLOAD SPLUNK!
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=103432&bid=230486&dat=121642
_______________________________________________
Jetty-support mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/jetty-support

--

Visit our website at www.roke.co.uk

Roke Manor Research Ltd, Roke Manor, Romsey, Hampshire SO51 0ZN, UK.

The information contained in this e-mail and any attachments is proprietary to
Roke Manor Research Ltd and must not be passed to any third party without
permission. This communication is for information only and shall not create or
change any contractual relationship.



-------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc. Do you grep through log files
for problems?  Stop!  Download the new AJAX search engine that makes
searching your log files as easy as surfing the  web.  DOWNLOAD SPLUNK!
<a href="http://sel.as-us.falkag.net/sel?cmd=lnk&kid3432&bid#0486&dat1642">http://sel.as-us.falkag.net/sel?cmd=lnk&kid3432&bid#0486&dat1642
_______________________________________________
Jetty-support mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/jetty-support
Reply | Threaded
Open this post in threaded view
|

Re: Local Ports SocketEndPoints and Jetty6 - specifying port 0

Greg Wilkins-5
In reply to this post by Millington, Steve

sorry to come to this conversation late....

I just added getLocalPort() to the connector API that will report
the actual port the connector is listening on.

I also too the opportunity to remove the use of SocketAddress as it
was preventing the BIO connector being used on older JVMs.

this is in SVN trunk now.

cheers


Millington, Steve wrote:

> I am trying to integrate Jetty6 as part of my unit testing suite. I will
> be wanting to connect to my jetty server using HTTP, and therefore am
> using one of the various connectors in Jetty6.
>
> When I specify the connector, I specify a port upon which to listen. For
> my test suite I want any number of these tests to be run at any time by
> any users (it is a unix box after all!). For traditional ServerSocket
> stuff, I can specify the port as zero, and then find out the actual port
> build listened to by using the getLocalPort() method of ServerSocket.
> What I want is to be able to do the same with Jetty.
>
> My question then - can I get hold of the information about which port a
> connector is actually listening on? It seems that the SocketEndPoint has
> such a thing, but how do I get hold of the SocketEndPoint for a
> particular connector?
>
> Thanks
>
> Steve
>



-------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc. Do you grep through log files
for problems?  Stop!  Download the new AJAX search engine that makes
searching your log files as easy as surfing the  web.  DOWNLOAD SPLUNK!
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=103432&bid=230486&dat=121642
_______________________________________________
Jetty-support mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/jetty-support
Reply | Threaded
Open this post in threaded view
|

RE: Local Ports SocketEndPoints and Jetty6 - specifying port 0

Millington, Steve
In reply to this post by Millington, Steve
Brilliant Greg - Thanks - I am not able to use the trunk myself, so I
will have to wait for beta 10 (or whatever).

Steve

-----Original Message-----
From: Greg Wilkins [mailto:[hidden email]]
Sent: 17 February 2006 12:37
To: [hidden email]
Subject: Re: Local Ports SocketEndPoints and Jetty6 - specifying port 0


sorry to come to this conversation late....

I just added getLocalPort() to the connector API that will report
the actual port the connector is listening on.

I also too the opportunity to remove the use of SocketAddress as it
was preventing the BIO connector being used on older JVMs.

this is in SVN trunk now.

cheers


Millington, Steve wrote:
> I am trying to integrate Jetty6 as part of my unit testing suite. I
will
> be wanting to connect to my jetty server using HTTP, and therefore am
> using one of the various connectors in Jetty6.
>
> When I specify the connector, I specify a port upon which to listen.
For
> my test suite I want any number of these tests to be run at any time
by
> any users (it is a unix box after all!). For traditional ServerSocket
> stuff, I can specify the port as zero, and then find out the actual
port
> build listened to by using the getLocalPort() method of ServerSocket.
> What I want is to be able to do the same with Jetty.
>
> My question then - can I get hold of the information about which port
a
> connector is actually listening on? It seems that the SocketEndPoint
has
> such a thing, but how do I get hold of the SocketEndPoint for a
> particular connector?
>
> Thanks
>
> Steve
>


--

Visit our website at www.roke.co.uk

Roke Manor Research Ltd, Roke Manor, Romsey, Hampshire SO51 0ZN, UK.

The information contained in this e-mail and any attachments is proprietary to
Roke Manor Research Ltd and must not be passed to any third party without
permission. This communication is for information only and shall not create or
change any contractual relationship.



-------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc. Do you grep through log files
for problems?  Stop!  Download the new AJAX search engine that makes
searching your log files as easy as surfing the  web.  DOWNLOAD SPLUNK!
<a href="http://sel.as-us.falkag.net/sel?cmd=lnk&kid3432&bid#0486&dat1642">http://sel.as-us.falkag.net/sel?cmd=lnk&kid3432&bid#0486&dat1642
_______________________________________________
Jetty-support mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/jetty-support
Reply | Threaded
Open this post in threaded view
|

Re: Local Ports SocketEndPoints and Jetty6 - specifying port 0

Greg Wilkins-5
Millington, Steve wrote:
> Brilliant Greg - Thanks - I am not able to use the trunk myself, so I
> will have to wait for beta 10 (or whatever).

You can get snapshot jars from ftp://ftp.mortbay.org/pub/maven2

cheers


> Steve
>
> -----Original Message-----
> From: Greg Wilkins [mailto:[hidden email]]
> Sent: 17 February 2006 12:37
> To: [hidden email]
> Subject: Re: Local Ports SocketEndPoints and Jetty6 - specifying port 0
>
>
> sorry to come to this conversation late....
>
> I just added getLocalPort() to the connector API that will report
> the actual port the connector is listening on.
>
> I also too the opportunity to remove the use of SocketAddress as it
> was preventing the BIO connector being used on older JVMs.
>
> this is in SVN trunk now.
>
> cheers
>
>
> Millington, Steve wrote:
>
>>I am trying to integrate Jetty6 as part of my unit testing suite. I
>
> will
>
>>be wanting to connect to my jetty server using HTTP, and therefore am
>>using one of the various connectors in Jetty6.
>>
>>When I specify the connector, I specify a port upon which to listen.
>
> For
>
>>my test suite I want any number of these tests to be run at any time
>
> by
>
>>any users (it is a unix box after all!). For traditional ServerSocket
>>stuff, I can specify the port as zero, and then find out the actual
>
> port
>
>>build listened to by using the getLocalPort() method of ServerSocket.
>>What I want is to be able to do the same with Jetty.
>>
>>My question then - can I get hold of the information about which port
>
> a
>
>>connector is actually listening on? It seems that the SocketEndPoint
>
> has
>
>>such a thing, but how do I get hold of the SocketEndPoint for a
>>particular connector?
>>
>>Thanks
>>
>>Steve
>>
>
>
>



-------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc. Do you grep through log files
for problems?  Stop!  Download the new AJAX search engine that makes
searching your log files as easy as surfing the  web.  DOWNLOAD SPLUNK!
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=103432&bid=230486&dat=121642
_______________________________________________
Jetty-support mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/jetty-support