-
Notifications
You must be signed in to change notification settings - Fork 0
Class JutilasNet
hxs edited this page Nov 29, 2019
·
10 revisions
Package jutilas.utils
File JutilasNet.java
JutilasNet is the class that contains the networking methods.
This class implements the singleton pattern, so to get the JutilasNet instance you need to use the getInstance()
method.
Example:
JutilasNet.getInstance()
.
- public ServerSocket createServerSocket(int... portList) throws NetworkExcepiton
- boolean isAvailablePort(int port)
throws NetworkExcepiton
This method create a local socket with first available.
Returns: Return the ServerSocket created.
Parameters:
- portList, list of ports where can try to create a socket
Exceptions:
- NetworkExcepiton, exception thrown if no ports available
Example:
ServerSocket serverSocket = JutilasNet.getInstance().createServerSocket(8080, 8585, 4545, 7070);
This check if the port passed is available.
Returns: Return true if the port is available, false otherwise.
Parameters:
- port, port to be checked
Example:
if (JutilasNet.getInstance().isAvailablePort(8080)) { // your code }