Re: [Simpleweb-Support] How do I cusotmize the port on which my server listens?
Brought to you by:
niallg
|
From: Dave A. <lar...@ms...> - 2013-04-10 14:35:26
|
Thanks for your help. Should I be able to telnet to that port after running that command? When I debug my JUnit test after having this
@BeforeClass
public static final void setupTestServer() throws IOException
{
Container container = new TestContainer(OK);
final Server server = new ContainerServer(container);
final Connection connection = new SocketConnection(server);
final SocketAddress address = new InetSocketAddress(8083);
connection.connect(address);
} // setupTestServer
I'm not able to telnet to localhost on port 8083. Below is the server I set up. I'm pausing the code through debugging so theoretically the server should still be alive (but I think I'm wrong on that one).
public class TestContainer implements Container {
private String defaultMsg;
public TestContainer(final String defaultMsg)
{
this.defaultMsg = defaultMsg;
} // TestContainer
public void handle(Request request, Response response) {
try {
final PrintStream body = response.getPrintStream();
long time = System.currentTimeMillis();
response.setValue("Content-Type", "text/plain");
response.setValue("Server", "Test/1.0 (Simple 5.0)");
response.setDate("Date", time);
response.setDate("Last-Modified", time);
body.println(defaultMsg);
body.close();
} catch(Exception e) {
e.printStackTrace();
}
}
}
Date: Tue, 9 Apr 2013 15:21:02 -0500
From: lma...@sm...
To: sim...@li...
Subject: Re: [Simpleweb-Support] How do I cusotmize the port on which my server listens?
Yes just change
new InetSocketAddress(8080);
with
new InetSocketAddress(9999);
or any port number you need.
Regards,
Laurent Marchal.
On 4/9/13 3:17 PM, Dave Alvarado wrote:
Hi, Thanks but I'm not seeing it. Neither the "HelloWorld"
example or the "AsynchronousService" seem to
change the default port of 8080 on which the server listens.
I
assume this line
SocketAddress address = new InetSocketAddress(8080);
refers to connecting to a running server.
Which
example are you referring to? - Dave
Date: Tue, 9 Apr 2013 14:43:43 -0500
From: lma...@sm...
To: sim...@li...
Subject: Re: [Simpleweb-Support] How do I cusotmize the port
on which my server listens?
Hi,
Here's an example from the tutorial. You might want to
read it http://www.simpleframework.org/doc/tutorial/tutorial.php
public static void main(String[] list) throws Exception {
Container container = new HelloWorld();
Server server = new ContainerServer(container);
Connection connection = new SocketConnection(server);
SocketAddress address = new InetSocketAddress(8080);
connection.connect(address);
}
Regards,
Laurent Marchal
On 4/9/13 11:38 AM, Dave Alvarado wrote:
Hi,
I'm using the latest version of the Simple
framework. How do I customize the port on which my
server listens? It seems to be 8080 by default, but
that port is being used by something else on my
system. I'm using the server creation from the
example:
public
class TestContainer implements Container {
public
void handle(Request
request, Response response) {
try
{
final
PrintStream body = response.getPrintStream();
long
time = System.currentTimeMillis();
response.set("Content-Type", "text/plain");
response.set("Server", "Test/1.0 (Simple 4.0)");
response.setDate("Date", time);
response.setDate("Last-Modified", time);
body.println("Hello World");
body.close();
} catch(Exception
e) {
e.printStackTrace();
}
}
}
Thanks, - Dave
------------------------------------------------------------------------------
Precog is a next-generation analytics platform capable of advanced
analytics on semi-structured data. The platform includes APIs for building
apps and a phenomenal toolset for data science. Developers can use
our toolset for easy data analysis & visualization. Get a free account!
http://www2.precog.com/precogplatform/slashdotnewsletter
_______________________________________________
Simpleweb-Support mailing list
Sim...@li...
https://lists.sourceforge.net/lists/listinfo/simpleweb-support
------------------------------------------------------------------------------
Precog
is a next-generation analytics platform capable of advanced
analytics on semi-structured data. The platform includes
APIs for building
apps and a phenomenal toolset for data science. Developers
can use
our toolset for easy data analysis & visualization. Get
a free account!
http://www2.precog.com/precogplatform/slashdotnewsletter
_______________________________________________
Simpleweb-Support mailing list
Sim...@li...
https://lists.sourceforge.net/lists/listinfo/simpleweb-support
------------------------------------------------------------------------------
Precog is a next-generation analytics platform capable of advanced
analytics on semi-structured data. The platform includes APIs for building
apps and a phenomenal toolset for data science. Developers can use
our toolset for easy data analysis & visualization. Get a free account!
http://www2.precog.com/precogplatform/slashdotnewsletter
_______________________________________________
Simpleweb-Support mailing list
Sim...@li...
https://lists.sourceforge.net/lists/listinfo/simpleweb-support
------------------------------------------------------------------------------
Precog is a next-generation analytics platform capable of advanced
analytics on semi-structured data. The platform includes APIs for building
apps and a phenomenal toolset for data science. Developers can use
our toolset for easy data analysis & visualization. Get a free account!
http://www2.precog.com/precogplatform/slashdotnewsletter
_______________________________________________
Simpleweb-Support mailing list
Sim...@li...
https://lists.sourceforge.net/lists/listinfo/simpleweb-support |