|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--com.act365.net.SocketUtils
SocketUtils provides various utility functions e.g. checksum calculations, functions to read and write numbers from bytestreams and a bytestream dump printer.
Constructor Summary | |
SocketUtils()
|
Method Summary | |
static short |
checksum(byte[] source,
byte[] destination,
byte protocol,
short length,
byte[] message,
int offset)
Specific checksum calculation used for the UDP and TCP pseudo-header. |
static short |
checksum(byte[] message,
int length,
int offset)
Standard internet checksum algorithm shared by IP, ICMP, UDP and TCP. |
static void |
dump(java.io.PrintStream printer,
byte[] buffer,
int offset,
int count)
Dumps a buffer in printable form. |
static int |
getProtocol()
Returns the protocol associated with the current DatagramSocketImpl . |
static boolean |
includeHeader()
Indicates whether the chosen protocol requires the user to include the IP header. |
static int |
intFromBytes(byte[] buffer,
int offset)
Converts consecutive bytes from a buffer into an int. |
static void |
intToBytes(int value,
byte[] buffer,
int offset)
Writes an int into a buffer. |
static long |
longFromBytes(byte[] buffer,
int offset)
Converts consecutive bytes from a buffer into a long. |
static void |
longToBytes(long value,
byte[] buffer,
int offset)
Writes a long into a buffer. |
static void |
setProtocol(java.lang.String protocollabel)
Sets the DatagramSocket factory to be used in the program. |
static short |
shortFromBytes(byte[] buffer,
int offset)
Converts consecutive bytes from a buffer into a short. |
static void |
shortToBytes(short value,
byte[] buffer,
int offset)
Writes a short into a buffer. |
Methods inherited from class java.lang.Object |
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
public SocketUtils()
Method Detail |
public static void setProtocol(java.lang.String protocollabel) throws java.io.IOException
DatagramSocket
factory to be used in the program.
The TCP, TCP/J, UDP and ICMP protocols are supported. TCP/J is a clone
of TCP that uses the IP protocol code 152. The addition of the Raw
prefix to the protocol name indicates that the user wishes to write his
own IP headers for the socket. (The option is not supported on Windows).
The Socket
and ServerSocket
factory objects
will be set for TCP-based protocols.protocol
- protocol to be used by DatagramSocket
objects in the apppublic static int getProtocol()
DatagramSocketImpl
.public static boolean includeHeader()
public static short checksum(byte[] message, int length, int offset)
public static short checksum(byte[] source, byte[] destination, byte protocol, short length, byte[] message, int offset)
public static short shortFromBytes(byte[] buffer, int offset)
public static int intFromBytes(byte[] buffer, int offset)
public static long longFromBytes(byte[] buffer, int offset)
public static void longToBytes(long value, byte[] buffer, int offset)
public static void intToBytes(int value, byte[] buffer, int offset)
public static void shortToBytes(short value, byte[] buffer, int offset)
public static void dump(java.io.PrintStream printer, byte[] buffer, int offset, int count)
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |