public class SocketGuard
extends java.lang.Object
Socket object and can close it after a given number of
milliseconds.| Constructor and Description |
|---|
SocketGuard(java.net.Socket socket,
long a_forceCloseAfterMS)
Creates a
SocketGuard for the given Socket, closing it after
a_forceCloseAfterMS milliseconds, or not if 0. |
| Modifier and Type | Method and Description |
|---|---|
void |
close()
Closes the
Socket this object holds and its InputStream and
OutputStream . |
static void |
close(java.net.Socket a_socket) |
static void |
close(SocketGuard a_socket)
Closes the given
SocketGuard object. |
static java.net.Socket |
createSocket(java.lang.String a_hostName,
int a_port,
long a_createTimeout)
Creates a new Socket.
|
static java.net.ServerSocket |
createVirtualBoxServerSocket(int a_port,
java.net.InetAddress a_excludeAddress) |
java.net.InetAddress |
getInetAddress() |
java.io.InputStream |
getInputStream() |
java.io.OutputStream |
getOutputStream() |
java.net.Socket |
getSocket() |
boolean |
isClosed()
Returns whether or not the internal Socket is closed or not.
|
static boolean |
isClosed(java.net.Socket a_socket) |
static boolean |
isClosedSupported()
Returns whether or not the Socket implementation used by this JVM supports
the
isClosed() method. |
void |
setSoTimeout(int ms) |
public SocketGuard(java.net.Socket socket,
long a_forceCloseAfterMS)
throws java.io.IOException
SocketGuard for the given Socket, closing it after
a_forceCloseAfterMS milliseconds, or not if 0.socket - The socket to guard.a_forceCloseAfterMS - The amount of time in milliseconds after which
the socket is forcefully closed. Might happen earlier due to
close(). 0 to leave it open.java.io.IOExceptionpublic java.net.Socket getSocket()
public java.net.InetAddress getInetAddress()
public java.io.InputStream getInputStream()
public java.io.OutputStream getOutputStream()
public void close()
throws java.io.IOException
Socket this object holds and its InputStream and
OutputStream .
If an IOException occurred along the way, it gets thrown.java.io.IOExceptionpublic static void close(SocketGuard a_socket)
SocketGuard object.a_socket - close()public boolean isClosed()
public void setSoTimeout(int ms)
throws java.net.SocketException
java.net.SocketExceptionpublic static boolean isClosedSupported()
isClosed() method.public static void close(java.net.Socket a_socket)
throws java.io.IOException
java.io.IOExceptionpublic static boolean isClosed(java.net.Socket a_socket)
a_socket - public static java.net.Socket createSocket(java.lang.String a_hostName,
int a_port,
long a_createTimeout)
throws java.lang.Exception
a_hostName - The hostname of the target or null for the loopback interface
(see java.net.Socket).a_port - The port of the target.a_createTimeout - The timeout for creating the new Socket in milliseconds. A timeout of
0 means to wait forever (until Socket creation is ready).java.lang.Exceptionpublic static java.net.ServerSocket createVirtualBoxServerSocket(int a_port,
java.net.InetAddress a_excludeAddress)
Copyright © 2023. All rights reserved.