...
}catch(BindException be){
System.out.println("Unable to bind port "+listenPort);
}catch(IOException ioe){
System.out.println("Unable to instantiate a ServerSocket on port "+listenPort);
}
....
多了个catch
}catch(BindException be){
System.out.println("Unable to bind port "+listenPort);
}catch(IOException ioe){
System.out.println("Unable to instantiate a ServerSocket on port "+listenPort);
}
....
多了个catch
解决方案 »
- 类型信息的问题
- 问一个语法问题Timer.this,这个是什么意思?
- JAVA中的实例变量为什么会有前向引用错误?
- GUI中 怎样设置界面显示的风格 具体使用哪个类? 感谢各位指导!
- 生成XML文件的困惑! 在线等
- 本人还是学生,今天刚决定学习JAVA,请教几个简单的问题.------------------------在线等!
- 做一名真正的java程序员,需要一些什么样的知识结构呢?up有分,
- 我编了一个servlet想用来接受网页的请求,网页有要求要放在什么目录吗?
- 关于继承和多态的一个疑惑,在线等
- JAVA一个简单的布局问题
- 请高手给我讲讲html文件中这两句是什么意思?(内详),有劳各位了!!1
- JBuilder6的s/n,谁能告诉我?
stringWriter.close();你的程序先编译吧........
你的程序很怪,你是每接到一个连接,只发一个信息给对方,只从对方接收一次信息??
System.out.println("Unable to instantiate a ServerSocket on port "+listenPort);
}
---------- javac ----------
MyServer.java:33: 'class' or 'interface' expected
public void connectionhandler(Socket incoming){
^
MyServer.java:60: 'class' or 'interface' expected
}
^
MyServer.java:60: 'class' or 'interface' expected
}
^
MyServer.java:22: cannot resolve symbol
symbol : method connectionhandler (java.net.Socket)
location: class MyServer
connectionhandler(incoming);
^
4 errors
Normal Termination
输出完成(耗时 6 秒)。
public void listen(){
try{
ServerSocket server=new ServerSocket(listenPort);
Socket incoming=null;
while(true){
incoming = server.accept();
connectionhandler(incoming);
}
}catch(BindException be){
System.out.println("Unable to bind port "+listenPort);
}catch(IOException ioe){
System.out.println("Unable to instantiate a ServerSocket on port "+listenPort);
}
}//多的}
}
>>>>>
OutputStream outToSocket= incoming.getOutputStream();
唉,开始我也像是这个,可是找了半天也没找见