All Packages  Class Hierarchy  This Package  Previous  Next  Index

Class netbula.ORPC.TCPServer

java.lang.Object
   |
   +----netbula.ORPC.Server
           |
           +----netbula.ORPC.TCPServer

public class TCPServer
extends Server
This class reprsents a TCP server. Usage sample:
         Svc svc = new msgsvc();
         TCPServer tcpserv = new TCPServer(8899, svc);
         if(tcpserv.unregister() == false ) {
            System.out.println("Fail to unregister tcp server");
         }
         if(tcpserv.register() == false ) {
            System.out.println("Fail to register tcp server");
         }else {
            System.out.println("registered TCP server on port:"+tcpserv.getPort());
            //run the TCP server in its own thread
            Thread t1 = new Thread(tcpserv);
            t1.start();
            System.out.println("Tcp server running");
         }


Constructor Index

 o TCPServer(int, Svc)
Construct a TCP server with an RPC service at a given port.
 o TCPServer(ServerSocket, Svc)
Use a bound server socket to create a TCP server.

Method Index

 o run()
Run the TCP server.

Constructors

 o TCPServer
 public TCPServer(int portn,
                  Svc mysvc) throws rpc_err
Construct a TCP server with an RPC service at a given port.

Parameters:
portn - the desired port number, if this is 0, use any free port.
mysvc - the RPC service.
 o TCPServer
 public TCPServer(ServerSocket ss,
                  Svc mysvc) throws rpc_err
Use a bound server socket to create a TCP server. This method allows one to run a server on an existing server socket.

Parameters:
ss - a bound socket
mysvc - the RPC service.

Methods

 o run
 public void run()
Run the TCP server. When this method is called, the thread enters an infinite loop to take RPC calls.

Overrides:
run in class Server

All Packages  Class Hierarchy  This Package  Previous  Next  Index