public class SocketExtensions extends Object
| Constructor and Description |
|---|
SocketExtensions() |
| Modifier and Type | Method and Description |
|---|---|
static boolean |
available(int port)
Checks if the given port at localhost is available.
|
static boolean |
available(String host,
int port)
Checks if the given port at the given host is available.
|
static void |
close(Socket clientSocket)
Close the given
Socket. |
static boolean |
closeClientSocket(Socket clientSocket)
Closes the given client socket.
|
static boolean |
closeServerSocket(ServerSocket serverSocket)
Closes the given ServerSocket.
|
static Socket |
newSocket(String host,
int port)
Factory method for a socket.
|
static Object |
readObject(InetAddress inetAddress,
int port)
Reads an object from the given socket InetAddress.
|
static Object |
readObject(int port)
Reads an object from the given port.
|
static Object |
readObject(Socket clientSocket)
Reads an object from the given socket object.
|
static Object |
readObject(String serverName,
int port)
Reads an object from the given socket InetAddress.
|
static void |
writeObject(InetAddress inetAddress,
int port,
Object objectToSend)
Writes the given Object to the given InetAddress who listen to the given
port.
|
static void |
writeObject(Socket socket,
int port,
Object objectToSend)
Writes the given Object to the given Socket who listen to the given port.
|
static void |
writeObject(String serverName,
int port,
Object objectToSend)
Writes the given Object.
|
public static boolean available(int port)
port - the port number.public static boolean available(String host, int port)
host - the host name.port - the port number.public static void close(Socket clientSocket) throws IOException
Socket.clientSocket - the client socketIOException - Signals that an I/O exception has occurred.public static boolean closeClientSocket(Socket clientSocket)
clientSocket - The client socket to close.public static boolean closeServerSocket(ServerSocket serverSocket)
serverSocket - The ServerSocket to close.public static Socket newSocket(String host, int port) throws IOException
host - the host name.port - the port number.IOException - is thrown if the port is not available or other network
errors.public static Object readObject(InetAddress inetAddress, int port) throws IOException, ClassNotFoundException
inetAddress - the InetAddress to read.port - The port to read.IOException - Signals that an I/O exception has occurred.ClassNotFoundException - the class not found exceptionpublic static Object readObject(Socket clientSocket) throws IOException, ClassNotFoundException
clientSocket - the socket to read.IOException - Signals that an I/O exception has occurred.ClassNotFoundException - the class not found exceptionpublic static Object readObject(int port) throws IOException, ClassNotFoundException
port - the portIOException - Signals that an I/O exception has occurred.ClassNotFoundException - the class not found exceptionpublic static Object readObject(String serverName, int port) throws IOException, ClassNotFoundException
serverName - The Name from the address to read.port - The port to read.IOException - Signals that an I/O exception has occurred.ClassNotFoundException - the class not found exceptionpublic static void writeObject(InetAddress inetAddress, int port, Object objectToSend) throws IOException
inetAddress - the inet addressport - The port who listen the receiver.objectToSend - The Object to send.IOException - Signals that an I/O exception has occurred.public static void writeObject(Socket socket, int port, Object objectToSend) throws IOException
socket - The Socket to the receiver.port - The port who listen the receiver.objectToSend - The Object to send.IOException - Signals that an I/O exception has occurred.public static void writeObject(String serverName, int port, Object objectToSend) throws IOException
serverName - The Name from the receiver(Server).port - The port who listen the receiver.objectToSend - The Object to send.IOException - Signals that an I/O exception has occurred.Copyright © 2015–2016 Alpha Ro Group UG (haftungsbeschrÀngt). All rights reserved.