Jump to content


 


Register a free account to unlock additional features at BleepingComputer.com
Welcome to BleepingComputer, a free community where people like yourself come together to discuss and learn how to use their computers. Using the site is easy and fun. As a guest, you can browse and view the various discussions in the forums, but can not create a new topic or reply to an existing one unless you are logged in. Other benefits of registering an account are subscribing to topics and forums, creating a blog, and having no ads shown anywhere on the site.


Click here to Register a free account now! or read our Welcome Guide to learn how to use this site.

Photo

Java Beginner Server Socket Question


  • Please log in to reply
1 reply to this topic

#1 Matthew.

Matthew.

  • Members
  • 66 posts
  • OFFLINE
  •  
  • Gender:Male
  • Location:Maple, Ontario
  • Local time:11:19 AM

Posted 12 March 2015 - 04:18 PM

Hi,

 

I've looked at a ton of examples out there for client/server side programming and so far they are all very similar with the exceptions of GUI based server applications. For example, I am writing a server side program on an IDE. Once I start the socket and it starts listening, the console of the IDE is basically constantly executing, waiting for clients to connect to it. So with that in mind, my question is, "Is it possible to have user input while the server is running from the server side?" What I am asking is if it is possible to have user input in the console while the server is running such as typing in "QUIT" so that the server can close it's sockets. I have yet to see this possible anywhere except on a GUI where a JButton helps stop the server and restarts it.

 

So far, what I have is a multi thread server, and two types of clients that can connect to it. One client (there will exist only one of this client) can control the server state and once the server's state changes, that is when the second client (there can be as many of these clients) can connect to the server and enter their input that will essentially be stored on the server. I looked everywhere to see if I could potentially turn the first client and fuse it with the server but to no success. Thanks in advance for any replies. Please let me know if the question doesn't make sense. I'll try to re word it. =)

 

Matt



BC AdBot (Login to Remove)

 


#2 JohnnyJammer

JohnnyJammer

  • Members
  • 1,118 posts
  • OFFLINE
  •  
  • Gender:Male
  • Location:QLD Australia
  • Local time:04:19 AM

Posted 12 March 2015 - 05:54 PM

I have never done Java but what you are askign for is an ARG[], if the argument mactehs the str.QUIT then exit.

 

So you would be listenign for the word "QUIT" but rememebr anyone could then use that word to kill the client/server socket so you need to implement authentication.






0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users