DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

+ Reply to Thread
Results 1 to 2 of 2
  1. #1
    Join Date
    Jun 2004
    Posts
    12

    Unhappy ObjectInputStream problems

    hi all here i have 2 program , one is the server and
    the other is the client.
    i am having problems with the ObjectInputStream
    it must read 5 objects "String" but here it is reading
    one or two Objects and then the connection Closes
    the Error Message is : connection reset
    plz help me with it coz i tried every thing .

    /******************************************************************/

    import java.io.* ;
    import java.net.* ;
    public class receive {
    public static void main(String[] args) {
    try {
    Socket s = new Socket("127.0.0.1" , 3000) ;
    ObjectInputStream in = new ObjectInputStream(s.getInputStream()) ;
    while (true) {
    String a = (String)in.readObject() ;
    System.out.println("OK " + a ) ;
    Thread.sleep(400) ;
    }
    }
    catch (Exception exc) {
    System.out.println("Error send "+exc.getMessage()) ;
    }
    }
    }


    class send {
    public static void main(String[] args) {

    try {
    ServerSocket ss = new ServerSocket (3000) ;
    Socket s = ss.accept() ;

    ObjectOutputStream out = new ObjectOutputStream(s.getOutputStream()) ;
    //out.flush() ;

    for (int i = 0 ; i < 3 ; i++)
    out.writeObject("Item :" + i) ;
    Thread.sleep(400) ;
    }
    catch (Exception exc) {
    System.out.println("Error send "+exc.getMessage()) ;
    }
    }
    }

    class Block implements Serializable{
    boolean clicked = false;
    String pieceColor ;
    String pieceSens ;

    Block(String c , String sens) {
    clicked = false ;
    pieceColor = c ; // pieceColor peut etre Red White nothing
    pieceSens = sens ; // sens peut etre up down nothing
    }


    }

  2. #2
    Join Date
    Feb 2004
    Posts
    808
    connection reset means either the client, server or some hardware inbetween, dropped the connection.. its a hard one to diagnose too, but its likely a network or firewall problem just as much as its a code problem..
    The 6th edict:
    "A thing of reference thing can hold either a null thing or a thing to any thing whose thing is assignment compatible with the thing of the thing" - ArchAngel, www.dictionary.com et al.
    JAR tutorial GridBag tutorial Inherited Shapes Inheritance? String.split(); FTP?

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


Top DevX Stories

Easy Web Services with SQL Server 2005 HTTP Endpoints
JavaOne 2005: Java Platform Roadmap Focuses on Ease of Development, Sun Focuses on the "Free" in F.O.S.S.
Wed Yourself to UML with the Power of Associations
Microsoft to Add AJAX Capabilities to ASP.NET
IBM's Cloudscape Versus MySQL


Sponsored Links