/**
* socket服务端的实现
*
* @author HongSoft
*/
public class ForumFileServer
{
static final int PORT=8000;
public static void main(String[] args)throws IOException
{
//启动 cacheMover线程,定时从cache中move掉部分过时的内容
ServerSocket s=new ServerSocket(PORT);
System.out.println("server started....");
try
{
while(true)
{
Socket socket=s.accept();
try
{
new PacketParserThread(socket);
}
catch(IOException e)
{
socket.close();
}
}
}
finally
{
s.close();
}
}
}
* socket服务端的实现
*
* @author HongSoft
*/
public class ForumFileServer
{
static final int PORT=8000;
public static void main(String[] args)throws IOException
{
//启动 cacheMover线程,定时从cache中move掉部分过时的内容
ServerSocket s=new ServerSocket(PORT);
System.out.println("server started....");
try
{
while(true)
{
Socket socket=s.accept();
try
{
new PacketParserThread(socket);
}
catch(IOException e)
{
socket.close();
}
}
}
finally
{
s.close();
}
}
}
此博客展示了Socket服务端的实现代码。定义了端口为8000,启动ServerSocket监听。在循环中不断接受客户端连接,为每个连接创建PacketParserThread处理。同时提到启动cacheMover线程,定时清理Cache中过时内容。
2588

被折叠的 条评论
为什么被折叠?



