-
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
}
}
-
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..
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
Forum Rules
|
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
|
Bookmarks