users@grizzly.java.net

Re: Make GrizzlyWebserver listen on a specific host rather localhost

From: Oleksiy Stashok <oleksiy.stashok_at_oracle.com>
Date: Tue, 12 Jul 2011 13:47:36 +0200

Hi,

can you pls. file an issue?
We'll gladly apply your patch.

Thanks.

WBR,
Alexey.

On 07/12/2011 01:29 PM, subin.mdl_at_gmail.com wrote:
> Hi
> I wanted to start my GrizzlyWebserver to listen to (IP,Port).
> By default I found that it listens only at localhost.
> After I downloaded the sourcecode,I found that by adding the following
> 2 mehods I am able to connect to IP,Port
>
> Following is the build version
> grizzly-http-1.9.35-SNAPSHOT.jar
> ory/${maven_repo}/com/sun/grizzly/grizzly-http/1.9.35-SNAPSHOT/grizzly-
> http-1.9.35-SNAPSHOT.jar
> [INFO]
> -----------------------------------------------------------------------
> -
> [INFO] BUILD SUCCESSFUL
> [INFO]
> -----------------------------------------------------------------------
> -
> [INFO] Total time: 6 minutes 43 seconds
> [INFO] Finished at: Tue Jul 12 16:44:12 IST 2011
> [INFO] Final Memory: 18M/43M
> [INFO]
> -----------------------------------------------------------------------
> -
>
> ClassName : GrizzlyWebServer.java
> package : com.sun.grizzly.http.embed
> code change : added the following methods
>
> //Method to create a Webserver
> public GrizzlyWebServer(String host, int port, int maxThreads, String
> webResourcesPath,
> boolean secure) throws UnknownHostException {
> this.port = port;
>
> createSelectorThread(host ,port, secure);
> setMaxThreads(maxThreads);
> this.webResourcesPath = webResourcesPath;
> }
>
>
> private void createSelectorThread(String host ,int port, boolean
> secure) throws UnknownHostException{
> if (secure) {
> SSLSelectorThread sslSelectorThread = new
> SSLSelectorThread();
> try {
> sslSelectorThread.setSSLImplementation(new
> JSSEImplementation());
> } catch (ClassNotFoundException e) {
> throw new IllegalStateException(e);
> }
> grizzlyListener = sslSelectorThread;
> } else {
> grizzlyListener = new SelectorThread();
> }
> ((SelectorThread) grizzlyListener).setPort(port);
> ((SelectorThread)
> grizzlyListener).setAddress(InetAddress.getByName(host));
> }
>
> when i added the above 2 methods and then when i used
> grizzly-http-1.9.35-SNAPSHOT.jar I was able to start a webserver liek
> this
> server = new GrizzlyWebServer("192.168.1.100",8080,5,".",false);
> Why is there no facility to start a webserver on any other host other
> than localhost?
> Can we add the above 2 methods into the source code?
>
> Many Thanks
> Subin