From owner-freebsd-java Thu Jan 17 0:13: 0 2002 Delivered-To: freebsd-java@freebsd.org Received: from web20409.mail.yahoo.com (web20409.mail.yahoo.com [216.136.226.128]) by hub.freebsd.org (Postfix) with SMTP id 9483937B417 for ; Thu, 17 Jan 2002 00:12:50 -0800 (PST) Message-ID: <20020117081250.6963.qmail@web20409.mail.yahoo.com> Received: from [210.77.118.103] by web20409.mail.yahoo.com via HTTP; Thu, 17 Jan 2002 00:12:50 PST Date: Thu, 17 Jan 2002 00:12:50 -0800 (PST) From: huang wen hui Subject: ServerSocket.accept() To: freebsd-java@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Sender: owner-freebsd-java@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.org hi, I wrote an app using ServerSocket, here is some code: try { port = Integer.parseInt (LissServerProperties.getProperty("System.control.port","5000")); } catch(java.lang.NumberFormatException nfEx) { port = SERVER_PORT; } ServerSocket serverSocket = new ServerSocket (port); serverSocket.setSoTimeout( 30 * 1000); System.err.println(new Date() +": Start NetSeis/IP Service, ready to accept Client."); Socket clientSocket = null; while (!bQuit) { try { clientSocket = serverSocket.accept (); ServerPI pi = new ServerPI (clientSocket); /** @todo QQQQQbug: * java.lang.OutOfMemoryError: unable to create new native thread * at java.lang.Thread.start(Native Method) * at cn.gd.seismology.liss.server.Server.start(Server.java:206) * at cn.gd.seismology.liss.server.Server.main(Server.java:285) */ new Thread (groupPI, pi, "ClientPI-" + pi.getRemoteHostName() + ":" + pi.getRemoteHostPort() ).start (); /** * we should not have many client establish at some time. */ try{ Thread.sleep(2000); } catch(InterruptedException iEx) {} } catch(java.io.InterruptedIOException iioEx) { //give a chance to handle bQuit continue; } catch(java.net.SocketException sEx) { //handle sun solaris "Interrupted System Calls" Exception. System.err.println(new Date()+":\tSUN(?)\t"+ sEx.getMessage()); try{ Thread.sleep(10* 1000); } catch(InterruptedException iEx) {} continue; } catch(java.lang.OutOfMemoryError oom) {//handle bug System.err.println("WARNING: \t" + oom.getMessage()); String sms = oom.getMessage()+"\r\n" + "shoud be OK, this is OS problem, especialy LINUX"; Result res = Result.buildResult (true, Result.PRIORITY_ERR, Result.TYPE_SMS,networkID, networkID+"IP", 0x0, new Date(), sms.getBytes() ); MsgManager.addResult(res); clientSocket.close(); System.gc(); } } serverSocket.close(); System.err.println(new Date() + "\t: Stop NetSeis/IP to accept more client login."); //System.exit(0); After serverSocket accept client, clientSocket will send Welcome msg to client. under Solaris 8 , linux+sunJDK1.3.1 and windows, my app works fine. I "telnet localhost 5000", telnet client will receive welcome msg. I run my app under FreeBSD4.4+JDK1.3.1p5. After some clients connect the server and run a certan times, I can not connect server any more: %telnet localhost 5000 Trying 127.0.0.1... Connected to localhost. Escape character is '^]'. telnet hang. It looks like serverSocket accept telnet, but not return clientSocket. Here is my netstat report: %netstat -na | grep -v 3306 |grep tcp tcp4 0 0 192.168.168.10.2136 192.168.169.10.4908 SYN_SENT tcp4 0 0 192.168.168.10.2134 192.168.168.10.2135 TIME_WAIT tcp4 0 0 *.2134 *.* LISTEN tcp4 0 0 *.2133 *.* LISTEN tcp4 0 0 192.168.168.10.2132 192.168.168.10.2131 TIME_WAIT tcp4 0 0 192.168.168.10.2130 192.168.168.28.1813 TIME_WAIT tcp4 0 0 192.168.168.10.2129 192.168.168.28.1809 TIME_WAIT tcp4 0 0 192.168.168.10.2128 192.168.168.28.1804 TIME_WAIT tcp4 0 0 192.168.168.10.2127 192.168.168.28.1794 TIME_WAIT tcp4 0 0 192.168.168.10.2126 192.168.168.28.1789 TIME_WAIT tcp4 0 0 192.168.168.10.2125 192.168.168.28.1784 TIME_WAIT tcp4 0 0 192.168.168.10.2124 192.168.168.28.1779 TIME_WAIT tcp4 0 0 192.168.168.10.2123 192.168.170.10.4780 TIME_WAIT tcp4 0 0 192.168.168.10.2122 192.168.170.10.4775 TIME_WAIT tcp4 0 0 192.168.168.10.2121 192.168.170.10.4770 TIME_WAIT tcp4 0 0 192.168.168.10.2120 192.168.170.10.4765 TIME_WAIT tcp4 0 0 192.168.168.10.2118 192.168.168.10.2119 TIME_WAIT tcp4 0 0 *.2118 *.* LISTEN tcp4 0 0 *.2117 *.* LISTEN tcp4 0 0 192.168.168.10.2114 192.168.168.10.2115 TIME_WAIT tcp4 0 0 192.168.168.10.2110 192.168.168.10.2111 TIME_WAIT tcp4 0 0 *.2110 *.* LISTEN tcp4 0 0 *.2109 *.* LISTEN tcp4 0 0 192.168.168.10.2108 192.168.168.10.2107 TIME_WAIT tcp4 0 0 192.168.168.10.2105 192.168.168.10.2106 TIME_WAIT tcp4 0 0 192.168.168.10.2103 192.168.168.10.2102 TIME_WAIT tcp4 0 0 192.168.168.10.2100 192.168.168.10.2101 TIME_WAIT tcp4 0 0 192.168.168.10.2098 192.168.168.10.2099 TIME_WAIT tcp4 0 0 192.168.168.10.2095 192.168.168.10.2092 TIME_WAIT tcp4 0 0 192.168.168.10.2094 192.168.168.10.2093 TIME_WAIT tcp4 0 0 192.168.168.10.2090 192.168.168.10.2091 TIME_WAIT tcp4 0 0 192.168.168.10.2088 192.168.168.10.2089 TIME_WAIT tcp4 0 0 192.168.168.10.2086 192.168.168.10.2085 TIME_WAIT tcp4 0 0 192.168.168.10.2083 192.168.168.10.2082 TIME_WAIT tcp4 0 0 192.168.168.10.2080 192.168.168.10.2081 TIME_WAIT tcp4 0 0 192.168.168.10.2078 192.168.168.10.2077 TIME_WAIT tcp4 0 0 192.168.168.10.2075 192.168.168.10.2076 TIME_WAIT tcp4 0 0 192.168.168.10.2073 192.168.168.10.2072 TIME_WAIT tcp4 0 0 192.168.168.10.2070 192.168.168.10.2071 TIME_WAIT tcp4 0 0 192.168.168.10.2068 192.168.168.10.2067 TIME_WAIT tcp4 0 0 192.168.168.10.2065 192.168.168.10.2066 TIME_WAIT tcp4 0 0 192.168.168.10.2063 192.168.168.10.2062 TIME_WAIT tcp4 0 0 127.0.0.1.5000 127.0.0.1.1736 CLOSE_WAIT tcp4 0 0 127.0.0.1.1736 127.0.0.1.5000 FIN_WAIT_2 tcp4 0 20 192.168.168.10.22 192.168.168.5.1211 ESTABLISHED tcp4 0 0 127.0.0.1.5000 127.0.0.1.1902 ESTABLISHED tcp4 0 0 127.0.0.1.1902 127.0.0.1.5000 ESTABLISHED tcp4 0 0 192.168.168.10.5000 192.168.168.10.1891 CLOSE_WAIT tcp4 0 0 192.168.168.10.5000 192.168.168.27.2254 CLOSE_WAIT tcp4 0 0 192.168.168.10.3382 192.168.170.10.2436 ESTABLISHED tcp4 0 0 192.168.168.10.3381 192.168.170.10.2433 ESTABLISHED tcp4 0 0 192.168.168.10.5000 192.168.170.10.2432 ESTABLISHED tcp4 0 0 192.168.168.10.5000 192.168.170.10.2430 ESTABLISHED tcp4 0 512 192.168.168.10.3084 192.168.169.10.1405 ESTABLISHED tcp4 0 0 192.168.168.10.3083 192.168.169.10.1402 ESTABLISHED tcp4 0 0 192.168.168.10.5000 192.168.169.10.1401 ESTABLISHED tcp4 0 0 192.168.168.10.5000 192.168.169.10.1399 ESTABLISHED tcp4 0 0 192.168.168.10.2982 192.168.168.28.3506 ESTABLISHED tcp4 0 0 192.168.168.10.2981 192.168.168.28.3505 ESTABLISHED tcp4 0 0 *.2981 *.* LISTEN tcp4 0 0 192.168.168.10.2975 192.168.168.28.5000 ESTABLISHED tcp4 0 0 192.168.168.10.5000 192.168.168.10.2974 ESTABLISHED tcp4 0 0 192.168.168.10.2974 192.168.168.10.5000 ESTABLISHED tcp4 0 0 192.168.168.10.2973 192.168.168.28.5000 ESTABLISHED tcp4 0 0 192.168.168.10.2915 192.168.168.28.3437 ESTABLISHED tcp4 0 0 192.168.168.10.2914 192.168.168.28.3435 ESTABLISHED tcp4 0 0 192.168.168.10.5000 192.168.168.28.3434 ESTABLISHED tcp4 0 0 192.168.168.10.5000 192.168.168.28.3432 ESTABLISHED tcp4 0 14336 127.0.0.1.4921 127.0.0.1.4922 ESTABLISHED tcp4 57344 0 127.0.0.1.4922 127.0.0.1.4921 ESTABLISHED tcp4 0 0 127.0.0.1.5000 127.0.0.1.4920 ESTABLISHED tcp4 0 0 127.0.0.1.4920 127.0.0.1.5000 ESTABLISHED tcp4 0 0 192.168.168.10.2344 192.168.169.10.3974 ESTABLISHED tcp4 0 0 192.168.168.10.2340 192.168.169.10.3973 ESTABLISHED tcp4 0 0 *.2340 *.* LISTEN tcp4 0 0 192.168.168.10.2338 192.168.169.10.5000 ESTABLISHED tcp4 0 24 192.168.168.10.5000 192.168.168.10.2337 ESTABLISHED tcp4 0 0 192.168.168.10.2337 192.168.168.10.5000 ESTABLISHED tcp4 0 0 192.168.168.10.2331 192.168.169.10.5000 ESTABLISHED tcp4 0 0 192.168.168.10.1056 192.168.170.10.1177 ESTABLISHED tcp4 0 0 192.168.168.10.1055 192.168.170.10.1176 ESTABLISHED tcp4 0 0 *.1055 *.* LISTEN tcp4 0 0 192.168.168.10.1045 192.168.170.10.5000 ESTABLISHED tcp4 0 0 192.168.168.10.5000 192.168.168.10.1044 ESTABLISHED tcp4 0 0 192.168.168.10.1044 192.168.168.10.5000 ESTABLISHED tcp4 0 0 192.168.168.10.1043 192.168.170.10.5000 ESTABLISHED tcp4 0 0 127.0.0.1.8005 *.* LISTEN tcp4 0 0 *.5000 *.* LISTEN tcp4 0 0 *.6000 *.* LISTEN tcp4 0 0 *.139 *.* LISTEN tcp4 0 0 *.80 *.* LISTEN tcp4 0 0 *.8008 *.* LISTEN tcp4 0 0 *.8080 *.* LISTEN tcp4 0 0 *.22 *.* LISTEN tcp46 0 0 *.22 *.* LISTEN tcp4 0 0 *.515 *.* LISTEN tcp6 0 0 *.515 *.* LISTEN I've fight with this problem for a long time. Does jdk1.3.1p5 have bug or my app have something wrong ? --hwh __________________________________________________ Do You Yahoo!? Send FREE video emails in Yahoo! Mail! http://promo.yahoo.com/videomail/ To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-java" in the body of the message