简体   繁体   中英

ServerSocket.accept()

While i am running my program i have svrSocket.accept() method..My program is automatically getting terminated when it reaches to svrSocket.accept() method. Please suggest what needs to be done.

Without example code or an error message for reference, according to the API , your application may not be catching one of the following exceptions:

  1. IOException
  2. SecurityException
  3. SocketTimeoutException
  4. IllegalBlockingModeException

Also, are you sure your application terminates? The only reason I ask is accept() blocks until a connection is made.

Here is what you need to provide before we can really help you.

  1. Stacktraces for exceptions that accept() might be throwing. If this is a simple console application look for those in the console of your IDE. There is a separate window that it runs in and shows output like this.

  2. Is the program truly terminating? accept() is a blocking call and blocks forever until another process connects to it through the socket. Have you tried running a client that connects to your server socket to see if it un blocks and continues to run? If you have to click the stop button, if multiple run windows are open then your program is simply blocked on the accept() call and it's working as designed.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM