Search...
FAQs
Subscribe
Pie
FAQs
Recent topics
Flagged topics
Hot topics
Best topics
Search...
Search within Sockets and Internet Protocols
Search Coderanch
Advance search
Google search
Register / Login
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
Jeanne Boyarsky
Ron McLeod
Paul Clapham
Liutauras Vilda
Sheriffs:
paul wheaton
Rob Spoor
Devaka Cooray
Saloon Keepers:
Stephan van Hulst
Tim Holloway
Carey Brown
Frits Walraven
Tim Moores
Bartenders:
Mikalai Zaikin
Forum:
Sockets and Internet Protocols
After sometime server didn't response but seem to like its running?
chandana nalin
Ranch Hand
Posts: 44
posted 8 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
After sometime server didn't response but seem to like its running?
i cant find what are the wrongs...
Server is running on centos 7.
ServerSocket ssock = null; try { ssock = new ServerSocket(portNo); while (true) { try { TCPClientThread client = null; ssock.setSoTimeout(3000); Socket sock = null; while (true) { sock = ssock.accept(); logger.log(Level.INFO, "Received connection request"); System.out.println("TCPServer->Got a connection request"); try { client = new TCPClientThread(sock, logger, props, tcpServer); client.start(); logger.log(Level.INFO, "TCPClientThread created"); } catch (EOFException sct) { logger.log(Level.INFO, "EOFException occured Remote IP:Port={0}", sock.getRemoteSocketAddress().toString()); System.out.println("EOFException occured, Remote IP:Port=" + sock.getRemoteSocketAddress().toString()); if (sock.getInputStream() != null) { sock.getInputStream().close(); } if (sock.getOutputStream() != null) { sock.getOutputStream().close(); } if (!sock.isClosed()) { sock.close(); } sock = null; ssock.close(); ssock = null; ssock = new ServerSocket(portNo); ssock.setSoTimeout(2000); } catch (StreamCorruptedException sct) { logger.log(Level.INFO, "StreamCorruptedException occured Remote IP:Port={0}", sock.getRemoteSocketAddress().toString()); if (null != sock.getInputStream()) { sock.getInputStream().close(); } if (null != sock.getOutputStream()) { sock.getOutputStream().close(); } if (!sock.isClosed()) { sock.close(); } } } } catch (SocketTimeoutException stex) { logger.log(Level.INFO, "SocketTimeoutException occured "); try { ssock.close(); ssock = null; ssock = new ServerSocket(portNo); ssock.setSoTimeout(2000); } catch (IOException ex) { Logger.getLogger(TCPServer.class.getName()).log(Level.SEVERE, null, ex); } } catch (Exception ex) { logger.log(Level.INFO, "Exception occured Server: {0}", ex.getMessage()); } } } catch (IOException ex) { Logger.getLogger(TCPServer.class.getName()).log(Level.SEVERE, null, ex); } }
30 seconds to difuse a loaf of bread ... here, use this tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
reply
Bookmark Topic
Watch Topic
New Topic
Boost this thread!
Similar Threads
StreamCorruptedException
StreamCorruptedException
problem with the StreamCorruptedException
EOFException on readObject()
StreamCorruptedException
More...