分享 2014-01-15 09:59
ljh404
浏览 3082 次
package server; import ; import ; import ; import ; import ; import ; import ; import ; //启动线程 public class Serveryancheng extends Thread{ public static void main(String[] args) { //启动服务线程 ("服务器启动成功"); new Serveryancheng().start(); } public void run(){ //服务器socket初始化 ServerSocket serversocket = null; Socket socket =null; ObjectOutputStream oos = null; ObjectInputStream ois= null; try { serversocket =new ServerSocket(((SysConstants.SYS_LISTENERPORT))); //设置死循环,设置监听 while(true){......此处省略很多字......} } catch (NumberFormatException e) { // TODO Auto-generated catch block (); } catch (IOException e) { // TODO Auto-generated catch block (); } catch (ClassNotFoundException e) { // TODO Auto-generated catch block (); } finally { try { //关闭流 (); (); (); } catch (IOException e) { // TODO Auto-generated catch block (); } } ("服务器终止"); //处理客户端发送的请求方法 //向客户端发送响应 } } SysConstants.SYS_LISTENERPORT为监听端口。 为取出.properties表中的与SysConstants.SYS_LISTENERPORT对应的port值。 运行ServerSocket(((SysConstants.SYS_LISTENERPORT)));之后就出现错误: 服务器启动成功 Exception in thread "Thread-0" at (:75)