udt.util
Class Util

java.lang.Object
  extended by udt.util.Util

public class Util
extends Object

helper methods


Field Summary
static long SYN
           
static double SYN_D
           
 
Constructor Summary
Util()
           
 
Method Summary
static void copy(InputStream source, OutputStream target)
          copy input data from the source stream to the target stream
static void copy(InputStream source, OutputStream target, long size, boolean flush)
          copy input data from the source stream to the target stream
static void doHolePunch(UDPEndPoint endpoint, InetAddress client, int clientPort)
          perform UDP hole punching to the specified client by sending a dummy packet.
static long getCurrentTime()
          get the current timer value in microseconds
static long getSYNTime()
          get the SYN time in microseconds.
static double getSYNTimeD()
           
static double getSYNTimeSeconds()
          get the SYN time in seconds.
static String hexString(MessageDigest digest)
           
static String readLine(InputStream input)
          read a line terminated by a new line '\n' character
static String readLine(InputStream input, char terminatorChar)
          read a line from the given input stream
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

SYN

public static final long SYN
See Also:
Constant Field Values

SYN_D

public static final double SYN_D
See Also:
Constant Field Values
Constructor Detail

Util

public Util()
Method Detail

getCurrentTime

public static long getCurrentTime()
get the current timer value in microseconds

Returns:

getSYNTime

public static final long getSYNTime()
get the SYN time in microseconds. The SYN time is 0.01 seconds = 10000 microseconds

Returns:

getSYNTimeD

public static double getSYNTimeD()

getSYNTimeSeconds

public static double getSYNTimeSeconds()
get the SYN time in seconds. The SYN time is 0.01 seconds = 10000 microseconds

Returns:

readLine

public static String readLine(InputStream input)
                       throws IOException
read a line terminated by a new line '\n' character

Parameters:
input - - the input string to read from
Returns:
the line read or null if end of input is reached
Throws:
IOException

readLine

public static String readLine(InputStream input,
                              char terminatorChar)
                       throws IOException
read a line from the given input stream

Parameters:
input - - the input stream
terminatorChar - - the character used to terminate lines
Returns:
the line read or null if end of input is reached
Throws:
IOException

copy

public static void copy(InputStream source,
                        OutputStream target)
                 throws Exception
copy input data from the source stream to the target stream

Parameters:
source - - input stream to read from
target - - output stream to write to
Throws:
IOException
Exception

copy

public static void copy(InputStream source,
                        OutputStream target,
                        long size,
                        boolean flush)
                 throws IOException
copy input data from the source stream to the target stream

Parameters:
source - - input stream to read from
target - - output stream to write to
size - - how many bytes to copy (-1 for no limit)
flush - - whether to flush after each write
Throws:
IOException

doHolePunch

public static void doHolePunch(UDPEndPoint endpoint,
                               InetAddress client,
                               int clientPort)
                        throws IOException
perform UDP hole punching to the specified client by sending a dummy packet. A local port will be chosen automatically.

Parameters:
client - - client address
Throws:
IOException

hexString

public static String hexString(MessageDigest digest)


Copyright © 2013 LittleShoot. All Rights Reserved.