|
2.17.2: 2011-06-17 | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object net.sf.basedb.util.SocketUtil
public class SocketUtil
This class contains some useful methods when working with sockets. Mainly for easy reading and writing to/from the sockets, and also for closing sockets without throwing exceptions.
Field Summary | |
---|---|
private static InetAddress |
LOCAL_HOST
|
Constructor Summary | |
---|---|
SocketUtil()
|
Method Summary | |
---|---|
static void |
close(InputStream in)
Close an InputStream without throwing any exceptions. |
static void |
close(Reader in)
Close a Reader without throwing any exceptions. |
static void |
close(ServerSocket socket)
Close a server socket without throwing any exceptions. |
static void |
close(ServerSocketChannel socket)
Close a server socket channel without throwing any exceptions. |
static void |
close(Socket socket)
Close a socket without throwing any exceptions. |
static void |
close(Writer out)
Close a Writer without throwing any exceptions. |
static InetAddress |
getLocalHost()
Get the local address of the local host. |
static InetAddress |
getPublicLocalHost()
Get the external address of the local host. |
static boolean |
isLocalHost(InetAddress address)
Check if the specfied address is the local host or not. |
static String |
read(Socket socket,
boolean shutdownInput)
Read input from a socket. |
static void |
send(Socket socket,
String output,
boolean shutdownOutput)
Send output to a socket. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
private static InetAddress LOCAL_HOST
Constructor Detail |
---|
public SocketUtil()
Method Detail |
---|
public static void send(Socket socket, String output, boolean shutdownOutput) throws IOException
socket
- The socket to send tooutput
- The output to sendshutdownOutput
- TRUE to close the output stream, FALSE to leave it open
IOException
- If there is an errorpublic static String read(Socket socket, boolean shutdownInput) throws IOException
socket
- The socket to read fromshutdownInput
- If the input stream should be closed or not
IOException
- If there is an errorpublic static void close(Socket socket)
socket
- The socket to closepublic static void close(ServerSocketChannel socket)
socket
- The socket to closepublic static void close(ServerSocket socket)
socket
- The socket to closepublic static void close(Writer out)
Writer
without throwing any exceptions.
out
- The writer to closepublic static void close(Reader in)
Reader
without throwing any exceptions.
in
- The reader to closepublic static void close(InputStream in)
InputStream
without throwing any exceptions.
in
- The stream to closepublic static boolean isLocalHost(InetAddress address)
address
- The address to check
public static InetAddress getLocalHost()
public static InetAddress getPublicLocalHost()
|
2.17.2: 2011-06-17 | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |