Skip navigation links
monq-2.0.0

Package monq.net

Simple tcp server and clients.

See: Description

Package monq.net Description

Simple tcp server and clients.

TcpServer, Service and ServiceFactory

The most basic class provided is TcpServer which handles all the nasty bits of setting up a network connection. For every incoming connection it asks a ServiceFactory to generate a Service. The Service is then plumbed up with the I/O streams of the network connection and its run() method called. When that finishes, the TcpServer cleans up the remains of the thread and closes the connection.

DfaService and DfaRunService

If you have a class that creates a DfaRun object, it can implement the interface ServiceFactory by wrapping the DfaRun into a into a DfaRunService.

Example

  public createService(java.io.InputStream in, 
                       java.io.OutputStream out) {
    DfaRun r = ... // do whatever is necessary 
                   // to create a DfaRun
    r.setIn(in);
    return new DfaRunService(r, new PrintStream(out));
  }

FilterServiceFactory and DistPipeFilter

To set up one element of a distributed filter pipeline, use a FilterServiceFactory. Suppose you have a ServiceFactory object called mySF. Then do the following:

  FilterServiceFactory fsf = new FilterServiceFactory(mySF);
  int port = 3456;
  new TcpServer(port, fsf).serve();
As a result, the service created for connections on the given port will read from its input stream instructions of how to fetch input data, normally from another upstream server. It establishes the connection and plumbs up your underlying service with the input from upstream and the output to downstream, all fully automatic.

To access a pipeline of filter services as described above, use DistPipeFilter or its command line wrapper DistFilter.

Skip navigation links
monq-2.0.0