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
compilation error
puja dayal
Ranch Hand
Posts: 65
posted 10 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
import java.net.*; import java.io.*; public class MyServer{ public static void main(String args[]){ ServerSocket serversocket = null; try{ serversocket = new ServerSocket(4444); System.out.println("listening"); while(true){ new MyServerThread(serversocket.accept()).start(); System.out.println("connected"); } }catch(IOException e){ System.out.println("could not listen to port: 4444"); System.exit(-1); } serversocket.close(); } }
i am getting a compilation error here ' unreachable statement serversocket.close()'
Ganesh Malaichamy
Greenhorn
Posts: 27
posted 10 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
Watch out for the line System.exit(-1). Whenever the exception occurs the last line will not get executed because of this System.exit.
Sachin H. Gupta
Greenhorn
Posts: 17
posted 10 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
The code is reachable but it must be enclosed in the try-catch block as it throws an IOExcpetion
reply
reply
Bookmark Topic
Watch Topic
New Topic
Boost this thread!
Similar Threads
Socket : MultiClient Server
Reading a binary file from a client to server
applet loading forever...
client / server (communication problem...)
sockets and printwriting
More...