日期:2014-05-20 浏览次数:20782 次
import javax.swing.*;
import java.awt.event.*;
import java.awt.*;
import java.net.*;
import java.io.*;
import java.util.*;
class ClientSocketListener extends Thread
{
private Socket socket;
private BufferedReader br;
ServerFrame serverFrame;
ClientSocketListener(Socket socket,ServerFrame serverFrame)
throws Exception
{
this.socket = socket;
br = new BufferedReader(new InputStreamReader(socket.getInputStream()));
this.serverFrame = serverFrame;
}
public void run()
{
String s = null;
try
{
while ( (s = br.readLine())!=null)
{
//向其他客户端发送
//ServerSocketThread.SendMsg(s);
//显示在Server的界面上
serverFrame.printServerMsg(s+"\r\n");
}
}
catch (Exception e)
{
e.printStackTrace();
}
}
}
class ServerSocketThread implements Runnable
{
ServerSocket serverSocket;
ServerFrame serverFrame;
static private ArrayList<PrintStream> sClientList = new ArrayList<PrintStream>();
static private ServerSocketThread serverSocketThread;
static public ServerSocketThread makeServerSocketThread(ServerFrame serverFrame)