socket = new Socket(address, port);
out = socket.getOutputStream();
pw = new PrintWriter(out);
is = socket.getInputStream();
pw.write(message);
pw.flush();
socket.shutdownOutput();
//接收服务器的相应
System.out.println("send message:" + message);
int count = 0;
while (count == 0) {
count = is.available();
}
byte[] b = new byte[count];
is.read(b);
reply = new String(b);上面是代码,直接运行是发不出信息的,也接收不到。调试的时候如果直接一步跳过也收不到 ,只有单步一步一步走才能发出去并受到信息
out = socket.getOutputStream();
pw = new PrintWriter(out);
is = socket.getInputStream();
pw.write(message);
pw.flush();
socket.shutdownOutput();
//接收服务器的相应
System.out.println("send message:" + message);
int count = 0;
while (count == 0) {
count = is.available();
}
byte[] b = new byte[count];
is.read(b);
reply = new String(b);上面是代码,直接运行是发不出信息的,也接收不到。调试的时候如果直接一步跳过也收不到 ,只有单步一步一步走才能发出去并受到信息
解决方案 »
- TftpClient的sendFile()报connection timeout?
- [申精][共同讨论]大家使用Struts的时候,会不会在JSP页面中使用其标签库?
- jdom可以获取某个节点的xml代码看看吗?
- 求高手来解决tomcat启动时加载配置文件问题,高手来啊
- 我在windows下编写的struts应用程序能不能在linux下使用
- 直接从控制台启动weblogic后配置成功的数据库连接池,在由jbuilder启动的weblogic下就变成UNAVAILABLE了?
- 快帮我解决问题(tomcat自带的例子怎么运行)吧。:( 解决了100分
- JBuilder8用向导生成的.jsp文件怎么不能修改?
- 新手请求帮助:Java编译器有哪些?J2EE和Java有什么关系?
- JDBC如何返回SQL执行时间
- 在Hibernate中封装方法,方法参数是动态参数,在给hql语句的占位符中赋值如何实现
- 使用CXF httpclient框架 找不到org/apache/http/config/Lookup类
while (count == 0) {
count = is.available();
}
byte[] b = new byte[count];
is.read(b);这种读取方式要用buffere类型的inputstrem才有用