Win a copy of Java Concurrency Live Lessons this week in the Threads forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Client Login Frame Hanged due to ServerSocket Accept Method  RSS feed

 
Shantanu Gangakhedkar
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello Friends ,
Shantanu here I am developing a Client server Application. I am using Object Input and Output Streams for Commnuication. I am passing Vector Object having elements User and Password. When I enter from Login Window User and Password. It Connects to Server but Login Window gets hanged .
My ServerApplication is class inherited from JFrame. And ClientLogin also.
But when it comes to Accept Method of ServerSocket client Login is hanged.I am invoking the ClientApplication class from ClientLogin Window.
I am sending Sample Code Also

public class ClientApplication {
boolean isConnected = true;
Socket client = null ;
OutputStream req = null;
ObjectOutput reqobject = null;
InputStream res = null;
ObjectInput resobject = null;
String UserName = null;
String Pwd = null;
BufferedReader in = null;
PrintWriter out = null;
Vector vc = null;
public ClientApplication(String strUser,String mstrPass) {
try {
UserName = mstrUser;
Pwd = mstrPass;
System.out.println("User :- " + UserName + " : " + "Pwd " + Pwd );
vc = new Vector();
}
catch ( Exception e) {
}
}
public void ConnectToServer(){
try {
Socket client = new Socket("cil",2001);
System.out.println("Inside Socket..");
InputStream res = client.getInputStream();
ObjectInput resobject = new ObjectInputStream(res);
OutputStream req = client.getOutputStream();
ObjectOutput reqobject = new ObjectOutputStream(req);
out = new PrintWriter(client.getOutputStream());
in = new BufferedReader(new InputStreamReader(client.getInputStream())); //
vc.addElement(UserName);
vc.addElement(Pwd);
System.out.println("Inside Connect to server..");
// reqobject.writeObject(vc);
reqobject.flush()

 
paul wheaton
Trailboss
Posts: 22262
Firefox Browser IntelliJ IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have a lot of suggestions, but none have anything to do with your problem.
I do wonder why you are putting objects and text down the same pipe. How is the server supposed to know which it is getting?
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!