/**
* 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();
}
}
}
Java Socket 服务端实现
本文介绍了一个使用Java实现的简单Socket服务端程序。该服务端监听8000端口,通过无限循环接受客户端连接请求,并为每个连接创建新的处理线程。一旦客户端连接,即启动新线程解析接收到的数据包。
2755

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



