-
关于socket的connection reset!5
我写的是SOCKET的客户端代码。。需要向服务端发送一个注册的请求。。
首先,我得发送一个字符串过去申请登录,登录成功对方会返回一个会话ID。然后我再发请求时要把这个ID带上,但我第2次用流向对方write的时候。就报连接重置的异常。
我的代码如下:
socket = new Socket(InetAddress.getByName(address),port); LOG.error("seccuse1"); if (socket != null) { LOG.error("DATAING"); InputStream in = socket.getInputStream(); OutputStream out = socket.getOutputStream(); String reqstinfo1 = reqstinfo1head + reqstinfo1body + reqstinfo1end; byte[] request = reqstinfo1.getBytes(); LOG.error("request1" + request); LOG.error("request1" + request); LOG.error("request1" + request); out.write(request); int length = in.read(returnHeadBytesArray); head = new String (returnHeadBytesArray); resultMap.put("reqstinfo1", head); LOG.error("head1" + head); LOG.error("head1" + head); LOG.error("head1" + head); String check_r2 = reqstinfo2head + reqstinfo2body + reqstinfo2end; LOG.error("check_r2" + check_r2); LOG.error("check_r2" + check_r2); LOG.error("check_r2" + check_r2); String infohe = ""; if (check_r2 != null && !"".equals(check_r2)) { if (changebody != null && !"".equals(changebody)) { reqstinfo2body = reqstinfo2body.substring(0, reqstinfo2body.length() - lengthc) + head.substring(beginc, beginc + lengthc); infohe = calcCheckSum(reqstinfo2body + reqstinfo2end); } String reqstinfo2 = reqstinfo2head + reqstinfo2body + reqstinfo2end + infohe; LOG.error("reqstinfo2" + reqstinfo2); LOG.error("reqstinfo2" + reqstinfo2); LOG.error("reqstinfo2" + reqstinfo2); LOG.error("reqstinfo2" + reqstinfo2); LOG.error("reqstinfo2" + reqstinfo2); if (reqstinfo2 != null && !"".equals(reqstinfo2)) { request = reqstinfo2.getBytes(); LOG.error("--------------------------------" + request.length); LOG.error("request2" + request); LOG.error("request2" + request); LOG.error("request2" + request); out.write(request); // Map param = new HashMap(); // param.put("request", reqstinfo2); // param.put("socket", socket); // param.put("arrsize", arrsize+""); // Map reMap = (Map)ESBClientService.call("zj/ismp/ecp/create/account2", "create/account", "翼聊开户", param); LOG.error("------------------------------"); returnHeadBytesArray = new byte[arrsize]; length = in.read(returnHeadBytesArray); head = new String (returnHeadBytesArray); // head = (String)reMap.get("head"); resultMap.put("reqstinfo2", head);
第42行执行的时候报的异常。
ERROR[PRIORITY] ncom.ct10000.esb.service.impl.MySocketService[CATEGORY]
--------------IOException----------------[MESSAGE]
2012-03-21 17:37:02,111 ERROR [STDERR] java.net.SocketException: Connection reset
2012-03-21 17:37:02,112 ERROR [STDERR] at java.net.SocketOutputStream.socketWrite(SocketOutputStream.java:96)
2012-03-21 17:37:02,112 ERROR [STDERR] at java.net.SocketOutputStream.write(SocketOutputStream.java:124)
我问过服务端的人。。他们说没有接收到我第2次传送的字符数组。请问这是为什么呢??菜鸟啊,没什么积分。求大神帮帮忙,弄了好几天了。。2012年3月21日 17:58
相关推荐
"java.net.SocketException Connection reset 解决方法" 在 Java 编程中,SocketException 是一种常见的异常,特别是在网络编程中。Conexion reset by peer 是一种特殊的 SocketException,它发生在客户端和服务器...
delphi客户端 ICS 代码。 上传 到 socket, 超大文件上传 4G,解决了 out of memory 和connection reset 问题
很多同学都说在用Eclispe出现“cannot connect to VM” 。现在给你们解决!
基于我们开源的Modbus协议栈实现的Modbus TCP客户端和服务器示例,使用VS2019开发。
python socket.error: [Errno ...这个错误是connection reset by peer.也就是传说的远端主机重置了此连接。原因可能是socket超时时间过长;也可能是request = urllib.request.urlopen(url)之后,没有进行request.cl
在linux上通过JDBC连接ORACLE 时总是出现 java.sql.SQLRecoverableException: IO Error: Connection reset 的问题
使用Phaser.js和Socket.io的2D MMORPG 在在线代码编辑器运行 安装指南 注意:如果您只想运行项目,则可以直接 如果要下载要在计算机上运行的项目,则必须做一些事情才能使其全部工作: 1.您将需要创建一个具有几个...
二、问题描述Connection reset by peer. 这个问题不多遇见,一般是由于下载的速度慢,导致超时,所以,需要调整一下超时时间。 解决办法:Run-time setting窗口中的‘Internet Protocol’-‘Preferences’设置set ...
;;;;;;;;... 1.... 2.... 3.... 4.... 5.... 6.... The syntax of the file is extremely simple.... Section headers (e.g.... at runtime.... There is no name validation.... (e.g.... previously set variable or directive (e.g....
connect the vlan 'n' to another VLAN using a socket connection -net socket[,vlan=n][,name=str][,fd=h][,mcast=maddr:port] connect the vlan 'n' to multicast maddr and port -net dump[,vlan=n][,file=f]...
AMD K6 II and AMD K6 III with Super Socket 7. IDT WinChip C6. CPU Overview and settings. 12. Pure 32-bit technology—The Pentium Pro. Pins and signals. Internal structure. Functional units of ...
connect the vlan 'n' to another VLAN using a socket connection -net socket[,vlan=n][,name=str][,fd=h][,mcast=maddr:port[,localaddr=addr]] connect the vlan 'n' to multicast maddr and port use '...
< > SCTP protocol connection tracking support (EXPERIMENTAL) < > UDP-Lite protocol connection tracking support < > Amanda backup protocol support < > FTP protocol support < > H.323 protocol ...
Changes in 2.4.6 (February 22, 2011): Brief summary : - Support more host OS to run on: - Include win64 native binary in the release. - Fixed failures on big endian hosts. - BIOS: Support for up to...
2.1.1. 关于资源(Resource) 2.1.2. 关于角色(Role) 2.1.3. 创建访问控制列表(ACL) 2.1.4. 注册角色(Role) 2.1.5. 定义访问控制 2.1.6. 查询 ACL 2.2. 精细的访问控制 2.2.1. 精细的访问控制 2.2.2. 除去访问...
just go tohttp://groups.yahoo.com/group/sakemail/History:0.9 - First released version0.9.1b -Fixed when a mail server reply on the connection with more than one line0.9.2b - I forget to return a ...
- A network connection and the TCP/IP networking software installed for the Network Tests Pro version only: - A serial port loop back plug for the serial port test. - A parallel port loop back plug...