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 webMetalab = new Socket("metalab.unc.edu", 80, "calzone.oit.unc.edu", 0);
Back to first slide
View graphic version