• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • paul wheaton
  • Jeanne Boyarsky
  • Ron McLeod
Sheriffs:
  • Paul Clapham
  • Liutauras Vilda
  • Devaka Cooray
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
Bartenders:

Client/Server networking

 
Ranch Hand
Posts: 43
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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:


 
Ranch Hand
Posts: 1067
2
IntelliJ IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
My favorite part of the code:
 
William Barnes
Ranch Hand
Posts: 1067
2
IntelliJ IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.???
 
(instanceof Sidekick)
Posts: 8791
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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)
Posts: 8791
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Forgot the StreamReader.
 
William Barnes
Ranch Hand
Posts: 1067
2
IntelliJ IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Here is the code I have working:


 
Yeah. What he said. Totally. Wait. What? Sorry, I was looking at this tiny ad:
Smokeless wood heat with a rocket mass heater
https://woodheat.net
reply
    Bookmark Topic Watch Topic
  • New Topic