---
title: "用socket实现的文件服务器(4)"
author: "hongsoft"
date: "2005-09-28T20:42:00Z"
tags: []
slug: "socket-4"
draft: false
lastmod: "2005-09-28T20:42:00Z"
id: 287448
url: "https://hongsoft.iteye.com/blog/287448"
---

/\**  
 * 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();  
           }  
       }  
}