Java Forums

Main Menu
Home
Today's Posts
FAQ
Search
Contact Us

Java Network
Java Tips
Java Tips Blog

Sponsored Links





Welcome to the Java Forums.

You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. By joining our free community, you will:

  • have access to post topics
  • communicate privately with other members (PM)
  • not see advertisements between posts
  • have the possibility to earn one of our surprises if you are an active member
  • access many other special features that will be introduced later.

Registration is fast, simple and absolutely free so please, join our community today!

If you have any problems with the registration process or your account login, please contact us.

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 12-13-2007, 10:28 AM
Moderator
 
Join Date: Nov 2007
Posts: 1,548
Java Tip will become famous soon enoughJava Tip will become famous soon enough
Looking for servers on ports
If you want to scan the ports on your machine and know on which ports servers are listening, use the code sample below. Alter the for loop according to the requirement.

Code:
for (int i = 0; i < 2000; i++) { try { System.out.println("Looking for "+ i); theSocket = new Socket(host, i); System.out.println("There is a server on port " + i); } catch (UnknownHostException e) { System.err.println(e); break; } catch (IOException e) { // must not be a server on this port } }
Bookmark Post in Technorati
Reply With Quote
Sponsored Links
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
How to scan your computer for ports in use Java Tip java.net 0 04-07-2008 09:13 PM
Servers supporting EJBeans ravian Enterprise JavaBeans 3 01-03-2008 11:44 AM
How to know the ports opened by JVM sandeepspatil Advanced Java 1 08-02-2007 02:51 PM
Configuring Enterprise Application Servers In NetBeans IDE JavaForums NetBeans 0 07-31-2007 12:13 AM
Ports In Java Peter Advanced Java 2 07-02-2007 07:44 PM


All times are GMT +3. The time now is 05:53 AM.


VBulletin, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2007, Crawlability, Inc.
Copyright ©2006 - 2007, www.java-forums.org