• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Client/Server networking

 
mike hengst
Ranch Hand
Posts: 43
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am not sure this is the right forum to ask my question but here goes. I am trying to write this application that calls for a client and a server along with other classes which I have not got to yet. Here is the problem: The client won't accept input. I had it working at one point but had to fix a bug and now it does not accept user input. If someone could just take a look at my code and tell me where my error is I would appreciate it greatly. Here are the client and server classes:


 
William Barnes
Ranch Hand
Posts: 986
Eclipse IDE Firefox Browser Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
My favorite part of the code:
 
William Barnes
Ranch Hand
Posts: 986
Eclipse IDE Firefox Browser Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The client won't accept input.

If this is the problem I don't understand why you are posting more than just the Client class.
You have all sorts of debugging print statements in the code already, so you should be able to give us a better clue as to where the problem is.

Is it possible that you are just missing a "System" in front of the last line here?
 
mike hengst
Ranch Hand
Posts: 43
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I posted my server and thread classes so you could see where I was sending the input from the client. out is my printwriter and outputs to the server the user input. The problem is once the client displays a menu it is supposed to accept user inputs such as 1 or 2 or 3 etc and sends that to the server to retrieve a file etc... Instead the cursor just sits there.???
 
Stan James
(instanceof Sidekick)
Ranch Hand
Posts: 8791
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Your client is connecting and then reading somethign from the server. Any chance the server is not sending anything?
here's a little socket project of my own:
http://www.surfscranton.com/architecture/CmdServer.htm
I'm new at sockets, and haven't implemented shutdown commands, so it's not perfect. I posted it on my site to solicit any and all constructive comments.
The client spawns a separate thread to read responses from the server, allowing the server to send zero to many responses to any request. The client will never get "hung" waiting for something from the server.
 
Stan James
(instanceof Sidekick)
Ranch Hand
Posts: 8791
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Forgot the StreamReader.
 
William Barnes
Ranch Hand
Posts: 986
Eclipse IDE Firefox Browser Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Am I missing something here? How do you ever get out of these loops?
 
mike hengst
Ranch Hand
Posts: 43
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Here is the code I have working:


 
Don't get me started about those stupid light bulbs.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic