0

I'm trying to create a very basic asynchronous server in Java (similar to http://msdn.microsoft.com/en-us/library/fx6588te.aspx in C#). All of the libraries I've seen for Java are way too complex for what I need and I'm wondering if there are any libraries that are simple and have a syntax similar to the C# example.

Edit: Why does plain sockets require root access to listen on the loopback, but nio doesn't require root?

3
  • 2
    would be good if you can spell out the requirements rather than making us read that link of yours. Commented Oct 1, 2011 at 18:22
  • Have you seen this tutorial? : "Writing the Server Side of a Socket" Commented Oct 1, 2011 at 18:23
  • Yup, but for concurrent connections, that tutorial recommends using a thread per socket... but that leads in to the link in the second answer. Commented Oct 1, 2011 at 18:33

2 Answers 2

2

try AsynchronousServerSocketChannel & AsynchronousSocketChannel

Sign up to request clarification or add additional context in comments.

Comments

1

This sounds like a job for Java's NIO (New I/O) ServerSocketChannel.

Be forewarned, though: this doesn't guarantee better performance. See:

2 Comments

Well I guess one thread per socket may just be the way to go, it seems. I'll write it using the threading then try nio to compare it.
Also, I just noticed that using a plain socket to listen to loopback requires root access, yet NIO doesn't require it... Is that normal?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.