SercverSocket 编译出错 Connection reset

问题描述

packageTest1;importjava.io.*;importjava.net.*;publicclassClientF{Sockets;ObjectOutputStreamoos;publicClientF(){try{s=newSocket("127.0.0.1",9999);oos=newObjectOutputStream(s.getOutputStream());//ThreadServerts=newThreadServer();//ts.start();//s.close();}catch(UnknownHostExceptione){//TODOAuto-generatedcatchblocke.printStackTrace();}catch(IOExceptione){//TODOAuto-generatedcatchblocke.printStackTrace();}TServertts=newTServer();tts.start();}publicstaticvoidmain(String[]args){//TODOAuto-generatedmethodstubClientFcf=newClientF();}classThreadServerextendsThread{booleanflag=true;publicvoidrun(){try{ObjectInputStreamois=newObjectInputStream(s.getInputStream());while(flag){System.out.println(ois.readObject().toString());}}catch(IOExceptione){//TODOAuto-generatedcatchblocke.printStackTrace();}catch(ClassNotFoundExceptione){//TODOAuto-generatedcatchblocke.printStackTrace();}}}classTServerextendsThread{booleanflag=true;publicvoidrun(){try{MessageFmf=newMessageF("AAA");oos.writeObject(mf);//oos.close();}catch(IOExceptione){//TODOAuto-generatedcatchblocke.printStackTrace();}}}}-------------------------------------------------------------------------------------------packageTest1;importjava.awt.*;importjava.awt.event.*;importjava.io.*;importjava.net.*;importjavax.swing.*;publicclassServerSocketF{PrintStreamps;booleanflag=true;JFramejf=newJFrame();JButtonjb=newJButton("发送");JTextAreajta1=newJTextArea();JTextAreajta2=newJTextArea();JPaneljp=newJPanel();JScrollPanejspoutput=newJScrollPane(jta1);JScrollPanejspinput=newJScrollPane(jta2);ObjectOutputStreamos;ServerSocketss;Sockets;publicServerSocketF(){jp.setLayout(newGridLayout(2,1,3,3));jp.add(jspoutput);jp.add(jspinput);jf.add(jp,BorderLayout.CENTER);jf.add(jb,BorderLayout.SOUTH);jf.setSize(200,200);jf.setVisible(true);jb.addActionListener(newActionListener(){publicvoidactionPerformed(ActionEvente){//mf.setMsg(jta2.getText());MessageFmf=newMessageF(jta2.getText());try{os.writeObject(mf);}catch(IOExceptione1){//TODOAuto-generatedcatchblocke1.printStackTrace();}jta2.setText("");}});try{ss=newServerSocket(9999);while(flag){s=ss.accept();os=newObjectOutputStream(s.getOutputStream());ThreadServerts=newThreadServer();ts.start();}//s.close();}catch(IOExceptione){//TODOAuto-generatedcatchblocke.printStackTrace();}}publicstaticvoidmain(String[]args){ServerSocketFsf=newServerSocketF();}classThreadServerextendsThread{booleanflag=true;publicvoidrun(){try{ObjectInputStreamois=newObjectInputStream(s.getInputStream());while(flag){System.out.println(ois.readObject().toString()+"n");}}catch(IOExceptione){//TODOAuto-generatedcatchblocke.printStackTrace();}catch(ClassNotFoundExceptione){//TODOAuto-generatedcatchblocke.printStackTrace();}}}}------------------------------------------------------------------------packageTest1;importjava.io.Serializable;publicclassMessageFimplementsSerializable{Stringmsg;publicMessageF(){}publicMessageF(Stringmsg){this.msg=msg;}publicStringtoString(){return"@:"+msg;}}----------------------------------------------------------------------------------报错为什么@:AAAjava.net.SocketException:Connectionresetatjava.net.SocketInputStream.read(UnknownSource)atjava.net.SocketInputStream.read(UnknownSource)atjava.io.ObjectInputStream$PeekInputStream.peek(UnknownSource)atjava.io.ObjectInputStream$BlockDataInputStream.peek(UnknownSource)atjava.io.ObjectInputStream$BlockDataInputStream.peekByte(UnknownSource)atjava.io.ObjectInputStream.readObject0(UnknownSource)atjava.io.ObjectInputStream.readObject(UnknownSource)atTest1.ServerSocketF$ThreadServer.run(ServerSocketF.java:96)

解决方案

解决方案二:
9999端口开了吗?你机器是不是有防火墙9999被拦截了吧
解决方案三:
该回复于2010-12-13 13:35:44被版主删除

时间: 2024-09-20 05:42:04

SercverSocket 编译出错 Connection reset的相关文章

ab压力测试报错: apr_socket_recv: Connection reset by peer (104)

使用ab对网站进行压力测试,开始设置并发500,可以正常使用,当设置并发为1000,则报错: apr_socket_recv: Connection reset by peer (104) 改服务端apache的maxclients参数,调大最大打开文件数,都不解决问题,最后才发现是因为ab的源码对ab的并发有限制,修改源码重新编译apache: 修改源码support目录下的ab.c文件,大概在1369行,修改为: return;} else {//apr_err("apr_socket_re

java.net.SocketException: Connection reset 解决方法_java

自从SEOTcs系统11月份24日更新了一下SEO得分算法以来,一直困扰我的一个问题出现了,java的数据job任务,在执行过程中会经常报以下的错误: "2011-12-03 18:00:32 DefaultHttpClient [INFO] I/O exception (java.net.SocketException) caught when processing request: Connection reset by peer: socket write error2011-12-03

xcode-学习objective-c 基础教程遇到问题 例题03.06 word-length-3 编译出错

问题描述 学习objective-c 基础教程遇到问题 例题03.06 word-length-3 编译出错 #import int main(int argc, const char * argv[]) { FILE *wordFile = fopen ("/tmp/words.txt", "r"); char word[100]; while (fgets(*word,99,wordFile)) \这一行编译出现"Thread 1:EXC_BAD_AC

chromium nacl编译出错

问题描述 chromium nacl编译出错 FAILED: Command '........outDebuggensdkwin_x86pnacl_newlibbinpnacl-ar @c:usersadmini~1.??appdatalocaltemptmpz8nl6n' returned non-zero exit stat us 1 [4/14478] ACTION nacl_lib_newlib: buil... plib_3ee1b6ebff4793d51aee0961182f8cb

JAVA代码编译出错:找不到符号,求解答

问题描述 JAVA代码编译出错:找不到符号,求解答 源代码: package com.tarena.shoot; import java.util.Random; //Airplane----敌机既是飞行物, public class Airplane extends FlyingObject implements Enemy{ private int speed = 2;//敌机走步的步数 public Airplane(){ image = ShootGame.airplane; width

nginx报错 "readv() failed (104: Connection reset by peer)"

  本文章来给大家介绍在使用nginx报错 "readv() failed (104: Connection reset by peer)" 错误的解决办法. 错误提示 [error] readv() failed (104: Connection reset by peer) while reading upstream, client: x.x.x.x, server: host.tld, request: "POST /script.php, ... 解决办法 php-

java特殊符号的输入后编译出错

问题描述 java特殊符号的输入后编译出错 java编写代码每次到特殊符号如|都编译不出来 求大神教教我 解决方案 已自行解决 Java 双竖线按住shift加""""就行了 || 解决方案二: 在java中,||为或符号,为一种特殊字符,所以在字符串中需要在前面加上转义字符"".

如果子类的构造方法中既没有显示调用基类构造方法,而基类中又没有无参数的构造方法,则编译出错。

问题描述 如果子类的构造方法中既没有显示调用基类构造方法,而基类中又没有无参数的构造方法,则编译出错. class Person { private String name; private int age; public void setName(String name) { this.name = name; } public void setAge(int age) { this.age = age; } public String getName(){ return name; } pu

openssl编译出错,真心快崩溃了。。。求解答

问题描述 openssl编译出错,真心快崩溃了...求解答 如题,小弟今天编译的openssl-0.9.8zg,在执行nmake -f msntdll.mak后,总是出现以下错误 -c .cryptoecec_asn1.c ec_asn1.c .cryptoecec_asn1.c(264) : error C2370: "ECPKPARAMETERS_it": 重定义:不同的 存储类 .cryptoecec_asn1.c(262) : 参见"ECPKPARAMETERS_it