FileDocCategorySizeDatePackage
TCPListener.javaAPI DocApache Axis 1.49477Sat Apr 22 18:56:52 BST 2006samples.transport.tcp

TCPListener

public class TCPListener extends Object implements Runnable
Listen for incoming socket connections on the specified socket. Take incoming messages and dispatch them.
author
Rob Jellinghaus (robj@unrealities.com)
author
Doug Davis (dug@us.ibm.com)

Fields Summary
static Log
log
private String
transportName
private static final String
AXIS_ENGINE
private int
port
private ServerSocket
srvSocket
private org.apache.axis.AxisEngine
engine
private boolean
done
static final String
wsdd
Constructors Summary
public TCPListener(String[] args)

        // look for -p, -d arguments
        try {
            Options options = new Options(args);
            port = new URL(options.getURL()).getPort();
        } catch (MalformedURLException ex) {
            log.error("Hosed URL: "+ex);
            System.exit(1);
        }

        try {
            srvSocket = new ServerSocket(port);
        } catch (IOException ex) {
            log.error("Can't create server socket on port "+port);
            System.exit(1);
        }

        log.info("TCPListener is listening on port "+port+".");
    
Methods Summary
public static voidmain(java.lang.String[] args)


          
        new TCPListener(args).run();
    
public voidrun()

        if (srvSocket == null) {
            return;
        }

        Socket sock;
        while (!done) {
            try {
                sock = srvSocket.accept();
                log.info("TCPListener received new connection: "+sock);
                new Thread(new SocketHandler(sock)).start();
            } catch (IOException ex) {
                /** stop complaining about this! it seems to happen on quit,
                    and is not worth mentioning.  unless I am confused. -- RobJ
                 */
                log.debug("Got IOException on srvSocket.accept: "+ex);
            }
        }