Easy to Learn Java: Programming Articles, Examples and Tips

Start with Java in a few days with Java Lessons or Lectures

Home

Code Examples

Java Tools

More Java Tools!

Java Forum

All Java Tips

Books

Submit News
Search the site here...
Search...
 
Search the JavaFAQ.nu
1000 Java Tips ebook

1000 Java Tips - Click here for the high resolution copy!1000 Java Tips - Click here for the high resolution copy!

Java Screensaver, take it here

Free "1000 Java Tips" eBook is here! It is huge collection of big and small Java programming articles and tips. Please take your copy here.

Take your copy of free "Java Technology Screensaver"!.

IP addresses are used to get packets to the right computer, but how do packets

JavaFAQ Home » Networking Go to all tips in Networking


Bookmark and Share

IP addresses are used to get packets to the right computer, but how do packets finds a program to which they are sent?

Usually every computer have several programs running at the same time and many of them communicate via Internet. Even more - all connections use the same physical Ethernet cable.

The packets are guided to the correct program according to its port number.

The port number is a 16 bit number and can be seen in an URL for example: https://www.javafaq.nu:80/

Because the port 80 is default when you use it, you will be redirected to http://www.javafaq.nu/

So, one application uses at least one port to communicate with another program via the same IP address. Actually think about IP address like about one big hotel and port number is a room in the hotel. Every guest leaves in its own room but to go to city and back home everybody uses the main door, at main entrance.

Many old programs use so named reserved port numbers, for example SSH uses port 22, telnet 23, FTP 21.

Also keep in mind that UNIX OSs reserve ports 1- 1023 for standard services - they are not accessible for programs you design . Windows has no such restriction, but if you design portable program it is wise to use ports above 1023. Actually much better to use ports from the end of the ports range, because many ports at the beginning are reserved (for well known port applications) and many are registered

Registered port means that some company officially registered that port to make sure that other programs are aware about it and will avoid to use it. The Registered Ports are in the range 1024-49151. The port usage in this range can lead to problems with your software on some networks, where post which you have chosen are already used by some another program.

I always use ports in Dynamic And/Or Private Posts Area, those from 49152 through 65535.

ActivePort Numbers, the whole known list is here

Working Java code examples ( network oriented) you can find below:

Authenticator
BindException
CacheRequest
CacheResponse
ConnectException
ContentHandler
DatagramPacket
DatagramSocket
HttpURLConnection
InetAddress
InetSocketAddress
MalformedURLException
MulticastSocket
PasswordAuthentication
ResponseCache
ServerSocket
Socket
SocketAddress
SocketException
UnknownHostException
URI
URISyntaxException
URL
URLClassLoader
URLConnection
URLStreamHandler
URLStreamHandlerFactory

Also some other Java code samples for the next four Java packages are below:

java.nio
java.nio.channels
java.nio.charset
java.nio.charset.spi

 Printer Friendly Page  Printer Friendly Page
 Send to a Friend  Send to a Friend

.. Bookmark and Share

Search here again if you need more info!
Custom Search



Home Code Examples Java Forum All Java Tips Books Submit News, Code... Search... Offshore Software Tech Doodling

RSS feed Java FAQ RSS feed Java FAQ News     

    RSS feed Java Forums RSS feed Java Forums

All logos and trademarks in this site are property of their respective owner. The comments are property of their posters, all the rest 1999-2006 by Java FAQs Daily Tips.

Interactive software released under GNU GPL, Code Credits, Privacy Policy