开发者

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 ne开发者_高级运维eds to be done.


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.


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜