专业版尚未开始(04-12-17)
三峡大学内的同学可以到http://FTP.ctgu.edu.cn/soft/down.PHP?act=up&id=2800下载
/*
* date: 2004-11-29 author:zhangyu6050;
* email: dazuibazhangyu@eyou.com
* ctgu (china three groges university)
* todo: 服务器主程序
* bugs:
*/
import util.DateUtil;
import Java.net.*;
import java.awt.*;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import java.io.*;
import javax.swing.*;
import java.applet.*;
import java.util.*;
public class ChatServer {
private int port = 1775; //端口号
private ServerSocket serverS; //服务器套节字
public static Broadcast broad;//通讯专用类,单态模式设计
private JTextArea display;
/**
*初始化
*/
public ChatServer() {
setupGui();
runServer();
}
public void runServer(){
try {
serverS=new ServerSocket(port);
} catch (IOException e2) {
showMSg("在指定端口无法监听"+e2.getMessage());
}
try {
broad= Broadcast.getInstence();//做好预备
while(true)
{
showMSg("等待接入......");
Socket socket = serverS.accept();
//记录登录时间
String s = DateUtil.format(Calendar.getInstance(),DateUtil.ymdhms)+"\r";
showMSg("接入时间:"+s);
//实例化一个代理
Angent angent = new Angent(socket);
//实例化一个服务线程