import java.io.*;
import java.net.*;
public class EchoChar{
public static void main(String[] args) throws IOException{
Socket echoSocket=null;
DataOutputStream out=null;
BufferedReader in=null;
try{
System.out.println("jjjjjjjj");
*** echoSocket= new Socket("127.0.0.1",8080);
System.out.println("kkkkkkk");
echoSocket.setReceiveBufferSize(1024);
echoSocket.setSendBufferSize(1024);
out=new DataOutputStream(echoSocket.getOutputStream());
in=new BufferedReader(new InputStreamReader(echoSocket.getInputStream()));
}catch(UnknownHostException e){
System.err.println("Don't know about host");
System.exit(1);
}catch(IOException e){
System.err.println("Couldn't get I/O for the conection");
System.exit(1);
}
BufferedReader stdIn=new BufferedReader(new InputStreamReader(System.in));
String userInput;
while((userInput=stdIn.readLine())!=null){
out.writeBytes(userInput);
out.writeByte('/');
System.out.println("echo:"+in.readLine());
}
out.close();
in.close();
stdIn.close();
echoSocket.close();
}
}这是一个创建一个socket用于本机通信的小程序编译可以通过
运行时每次只输出:
jjjjjjjj
Couldn't get I/O for the conection是不是我打星号的那行不对啊 到底是什么原因呢???
import java.net.*;
public class EchoChar{
public static void main(String[] args) throws IOException{
Socket echoSocket=null;
DataOutputStream out=null;
BufferedReader in=null;
try{
System.out.println("jjjjjjjj");
*** echoSocket= new Socket("127.0.0.1",8080);
System.out.println("kkkkkkk");
echoSocket.setReceiveBufferSize(1024);
echoSocket.setSendBufferSize(1024);
out=new DataOutputStream(echoSocket.getOutputStream());
in=new BufferedReader(new InputStreamReader(echoSocket.getInputStream()));
}catch(UnknownHostException e){
System.err.println("Don't know about host");
System.exit(1);
}catch(IOException e){
System.err.println("Couldn't get I/O for the conection");
System.exit(1);
}
BufferedReader stdIn=new BufferedReader(new InputStreamReader(System.in));
String userInput;
while((userInput=stdIn.readLine())!=null){
out.writeBytes(userInput);
out.writeByte('/');
System.out.println("echo:"+in.readLine());
}
out.close();
in.close();
stdIn.close();
echoSocket.close();
}
}这是一个创建一个socket用于本机通信的小程序编译可以通过
运行时每次只输出:
jjjjjjjj
Couldn't get I/O for the conection是不是我打星号的那行不对啊 到底是什么原因呢???
解决方案 »
- 使用jdk1.7,但是新语法却不能使用,这是为什么?
- 新手!!苦恼(求指教 不胜感激)
- jar文件混淆问题
- 【急】 netbeans 6.1 中单击按钮关闭窗口问题
- 把某月的日期(包括星期)用JSP表示出来。
- error: cannot read: HelloWorld.java
- [Microsoft][SQLServer 2000 Driver for JDBC]Error establishing socket.的错误消息
- SQL语句小问题!问题解决马上给分!
- 表格及相关类的使用方法
- php 转为 java!!!!!!! (来者有分!)
- 小弟跪地求程序,求各位大人帮忙!!!!!!
- 菜鸟上路,使用eclipse遇到的问题!
怎么问工资调查的帖子那么热问技术的都没人理??
失望ing