Choosing a Local Port
You can also specify a local port number,
Setting the port to 0 tells the system to randomly choose an available port.
If you need to know the port you're connecting from, you can always get it with getLocalPort().
Socket webSunsite = new Socket("sunsite.unc.edu", 80, "calzone.oit.unc.edu", 0);
Previous slide
Next slide
Back to first slide
View graphic version