servicemonitor.java

来自「First of all, the Applet-phone is a SIP 」· Java 代码 · 共 72 行

JAVA
72
字号
/* * ServiceMonitor.java * * Created on October 15, 2003, 9:43 AM */package gov.nist.security.bcs.monitor;import java.io.*;import java.net.*;/** * Class instantiated at the starting of a service * this class will open a socket towards the stateless proxy * and send the sipURI and the port of the registered service * @author  DERUELLE Jean */class ServiceMonitor implements Runnable {    /**the service monitor thread */    private Thread monitorThread= null;        /**the socket which will send information to the stateless proxy*/    private Socket socket = null;    /**the IP Address where this service is uploaded and running*/    private String ipAddress= null;    /**the port on wich to Start the socket*/    private String port= null;    /**the main class name of the service*/    private String serviceName= null;    /**Output of the socket*/    private PrintWriter sout =null;        /** Creates a new instance of ServiceMonitor */    public ServiceMonitor() {            }        /** Creates a new instance of ServiceMonitor     * @param ipAddress - the IP Address where this service is uploaded and running     * @param port - the port on wich to Start the socket     * @param serviceName - the main class name of the service     */    public ServiceMonitor(String ipAddress,String port, String serviceName) {        this.ipAddress=ipAddress;        this.port=port;        this.serviceName=serviceName;    }        /**     * start the monitor thread     */    public void start() {        if (monitorThread== null) {            monitorThread= new Thread(this);            monitorThread.start();        }    }    /**     * @see java.lang.Runnable#run()     */    public void run() {                int portNumber = 0;	try {	    	    try {		portNumber = Integer.parseInt(port);                	    }	    catch (NumberFormatException e) {		System.err.println("Wrong port number");		System.exit(1);	    }	    socket = new Socket(ipAddress, portNumber);            sout = new PrintWriter(socket.getOutputStream());            sendStartedNotification();	    /*System.out.println("Connection successfull on "+socket.getInetAddress()+" port n

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?