By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
428,529 Members | 864 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 428,529 IT Pros & Developers. It's quick & easy.

question: how long would it take

P: n/a
I am doing some research regarding writing a small webserver in java...

So my question is:

How long would it take to write a small webserver in java, by say some
one who has little experience in java but has a strong programming
background ?

Would it be possible to run this from a Windoze CE ?
Any ideas and links greatly appreciated !
Jul 17 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
John Smith wrote:
I am doing some research regarding writing a small webserver in java...

So my question is:

How long would it take to write a small webserver in java, by say some
one who has little experience in java but has a strong programming
background ?

Would it be possible to run this from a Windoze CE ?
Any ideas and links greatly appreciated !

Well depends on what features you want to support. But i see it as
maby, if you don't have the knowledge, as a 50 hr job to have a decent
HTTP 1.1 server going. If you do have experience with parsing and stuff
you might be looking at around 20 hrs...

Thats just my estimate.
Jul 17 '05 #2

P: n/a
As Torsten said, it's pretty simple. Here is a snippet (for illustration
only... you could punch many holes in this :-) It does not parse the
HTTP headers or anything like that, but that's pretty simple.

public class SampleServer
{

public static void main(String[] args)
{
if (args.length != 1)
{
System.err.println(USAGE);
}

int port = -1;

try
{
port = Integer.parseInt(args[0]);
}
catch (NumberFormatException e)
{
System.err.println(USAGE);
System.exit(1);
}

try
{
ServerSocket ss = new ServerSocket(port);
mDispatchThread = new DispatchThread(ss);
mDispatchThread.start();
}
catch (IOException e)
{
DHLLog.getInstance().fatal(SampleServer.class, "error
setting up socket", e);
}
}

static class DispatchThread
extends Thread
{
DispatchThread(ServerSocket ss)
{
mSS = ss;
}

/* (non-Javadoc)
* @see java.lang.Runnable#run()
*/
public void run()
{
Socket s = null;
char[] buffer = new char[1024];

do {
try {
s = mSS.accept();
}
catch (IOException e) {
System.err.println("Error while in accept: " +
e.getMessage());
System.exit(1);
}

// REQUEST: s.getInputStream()
// RESPONSE: s.getOuputStream()
while (true);

}

private boolean mKeepRunning = true;
private ServerSocket mSS;
}

private static final String USAGE = "usage: SampleServer <portNumber>";
}

John Smith wrote:
I am doing some research regarding writing a small webserver in java...

So my question is:

How long would it take to write a small webserver in java, by say some
one who has little experience in java but has a strong programming
background ?

Would it be possible to run this from a Windoze CE ?
Any ideas and links greatly appreciated !


Jul 17 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.