
/* 
 * The SipServer object serves as a very simple SIP server or a front-end
 * to the UAServer (user agent server) by listening for incoming calls 
 * and starts a UAServer thread to handle the call.  It is implemented 
 * as a background thread within Simphony, therefore should be running
 * all the time.
 *
 * Author: Janet H. Park
 * Date: August, 1998
 *
 */

import java.io.*;
import java.net.*;
import java.util.*;

public class SipServer extends Thread {

	public SipServer() {
		System.out.println("SipServer started.");
	}

	public void run() {
		ServerSocket s = null;
		Socket sock;
 
		try {
			s = new ServerSocket(5060, 100);
			while (true) {
				// wait here and listen for a connection
				sock = s.accept();
				// fork a SIP server thread to handle an incoming session
				System.out.println("User Agent Server started");
				UAServer uas = new UAServer(sock);
				uas.setDaemon(false);
				uas.start();
			}
		} catch (IOException e) { 
			System.out.println("SipServer: IOException");
		}
} // end of run
} // end of class SipServer

