Skip navigation links
eBus
4.5.0

Package net.sf.eBus.net

Adds a layer between the application and the java.nio.channels package.

See: Description

Package net.sf.eBus.net Description

Adds a layer between the application and the java.nio.channels package. java.nio.channels.Selector is placed into a separate SelectorThread. AsyncDatagramSocket, AsyncMulticastSocket, AsyncSocket and AsyncServerSocket encapsulate a java.nio.channel.Channel and registers that channel with the selector thread. The selector thread informs these asynchronous sockets when I/O operations are possible.

The selector thread is automatically started by the network package on behalf of the application. The selector thread is a daemon thread and terminates when the application exits.

Upon successfully completing the I/O operation, the asynchronous socket calls its listener, passing the operation results. I/O operations and listener calls are performed in the SelectorThread.

This package follows the java.net API design, provide separate classes for multicast and non-multicast datagram sockets. Project developers' experience shows that these two socket types are distinct in use. There is no need to open one UDP socket and use it for both multicast and non-multicast purposes. Further, multicast UDP sockets require a different binding than non-multicast UDP sockets (if any), resulting in using one UDP socket for both purposes problematic.

The eBus network package provides three utility classes:

  1. InetServices: This is Dan Anderson's utility class with some modifications. This fills in functionality missing from java.net: translating a TCP or UDP service name into a port number.
  2. InetAddressComparator: provides comparison between two java.net.InetAddress instances.
  3. InetSocketAddressComparator: provides comparison between two java.net.InetSocketAddress instances.
Skip navigation links
eBus
4.5.0