barchart-udt-core
2.3.0-SNAPSHOT / 2013-05-13T01:37:38.485-0500

com.barchart.udt
Class SocketUDT

java.lang.Object
  extended by com.barchart.udt.SocketUDT

public class SocketUDT
extends Object

UDT native socket wrapper

note: current implementation supports IPv4 only (no IPv6)


Field Summary
static int DEFAULT_ACCEPT_QUEUE_SIZE
          Maximum number of connections queued in listening mode by accept()
static int DEFAULT_FILE_BLOCK_SIZE
          Block size used by sendFile(File, long, long)
static int DEFAULT_MAX_SELECTOR_SIZE
          Maximum number sockets that can participate in a SelectorUDT.select() operation; see epoll.h to confirm current limit
static int DEFAULT_MIN_SELECTOR_TIMEOUT
          Minimum timeout of a SelectorUDT.select() operations.
static int INFINITE_TTL
          infinite message time to live;
static boolean INIT_OK
          Helper value that can be checked from CCC class and force JNI library load
protected static org.slf4j.Logger log
           
static int SIGNATURE_JNI
          JNI Signature that must match between java code and c++ code on all platforms; failure to match will abort native library load, as an indication of inconsistent build.
static int TIMEOUT_INFINITE
          infinite timeout:
static long TIMEOUT_NONE
          zero timeout:
static int UDT_EXCEPT_INDEX
          UDT::select() sizeArray/sizeBuffer index offset for EXCEPTION report
static int UDT_READ_INDEX
          UDT::select() sizeArray/sizeBuffer index offset for READ interest
static int UDT_SIZE_COUNT
          UDT::select() sizeArray/sizeBuffer size count or number of arrays/buffers
static int UDT_WRITE_INDEX
          UDT::select() sizeArray/sizeBuffer index offset for WRITE interest
 
Constructor Summary
  SocketUDT(TypeUDT type)
          "Primary" socket.
protected SocketUDT(TypeUDT type, int socketID)
          "Secondary" socket.
 
Method Summary
 SocketUDT accept()
           
protected  SocketUDT accept0()
           
 void bind(InetSocketAddress localSocketAddress)
           
protected  void bind0(InetSocketAddress localSocketAddress)
           
static void cleanup()
          Cleans up global JNI references and the UDT library.
 void clearError()
          Clear error status on a socket, if any.
protected  void clearError0()
           
 void close()
          Close socket if not already closed.
protected  void close0()
           
 void connect(InetSocketAddress remoteSocketAddress)
          Connect to remote UDT socket.
protected  void connect0(InetSocketAddress remoteSocketAddress)
           
protected static void epollAdd0(int epollID, int socketID, int epollOpt)
           
protected static int epollCreate0()
           
protected static void epollRelease0(int epollID)
           
protected static void epollRemove0(int epollID, int socketID)
           
protected static void epollUpdate0(int epollID, int socketID, int epollMask)
          update epoll mask
protected static int epollVerify0(int epollID, int socketID)
          query epoll mask
protected static int epollWait0(int epollID, IntBuffer readBuffer, IntBuffer writeBuffer, IntBuffer sizeBuffer, long millisTimeout)
           
 boolean equals(Object otherSocketUDT)
          Note: equality is based on socketID.
protected  void finalize()
          NOTE: catch all exceptions; else prevents GC
 ErrorUDT getError()
          Error object wrapper.
 int getErrorCode()
          Error code set by last operation on a socket.
protected  int getErrorCode0()
           
 String getErrorMessage()
          Native error message set by last operation on a socket.
protected  String getErrorMessage0()
           
 int getListenQueueSize()
           
 InetAddress getLocalInetAddress()
           
 int getLocalInetPort()
           
 InetSocketAddress getLocalSocketAddress()
           
 boolean getMessageIsOdered()
          default isOrdered value used by sendmsg mode
 int getMessageTimeTolLive()
          default timeToLive value used by sendmsg mode
<T> T
getOption(OptionUDT<T> option)
           
protected  Object getOption0(int code, Class<?> klaz)
           
 int getReceiveBufferSize()
          Get maximum receive buffer size.
 InetAddress getRemoteInetAddress()
           
 int getRemoteInetPort()
           
 InetSocketAddress getRemoteSocketAddress()
           
 boolean getReuseAddress()
          Check if local bind address is set to reuse mode.
 int getSendBufferSize()
          Get maximum send buffer size.
protected static int getSignatureJNI0()
          Verify that java code and c++ code builds are consistent.
 int getSoLinger()
          Get time to linger on close (seconds).
 int getSoTimeout()
          Get "any blocking operation" timeout setting.
protected  int getStatus0()
           
 int hashCode()
          Note: uses socketID as hash code.
protected  boolean hasLoadedLocalSocketAddress()
          Load localSocketAddress value.
protected  boolean hasLoadedRemoteSocketAddress()
          Load remoteSocketAddress value.
 int id()
          native socket descriptor id; assigned by udt library
protected static void initClass0()
          Call this after loading native library.
protected  int initInstance0(int typeCode)
          used by default constructor
protected  int initInstance1(int socketUDT)
          used by accept() internally
 boolean isBlocking()
          Check if socket is in strict blocking mode.
 boolean isBound()
          Check if socket is bound.
 boolean isClosed()
          Check if socket is closed.
 boolean isConnected()
          Check if KindUDT.CONNECTOR socket is connected.
 boolean isNonBlocking()
          Check if socket is in strict non-blocking mode.
 boolean isOpen()
          Check if socket is open.
 boolean isRendezvous()
           
 void listen(int queueSize)
           
protected  void listen0(int queueSize)
           
 MonitorUDT monitor()
          performance monitor; updated by updateMonitor(boolean) in JNI
 int receive(byte[] array)
          receive into byte[] array upto array.length bytes
 int receive(byte[] array, int position, int limit)
          receive into byte[] array upto size=limit-position bytes
 int receive(ByteBuffer buffer)
          receive into DirectByteBuffer; upto Buffer.remaining() bytes
protected static int receive0(int socketID, int socketType, byte[] array)
          receive into a complete byte array
protected static int receive1(int socketID, int socketType, byte[] array, int position, int limit)
          receive into a portion of a byte array
protected static int receive2(int socketID, int socketType, ByteBuffer buffer, int position, int limit)
          receive into a DirectByteBuffer
 long receiveFile(File file, long offset, long length)
          Receive file from remote peer.
protected static long receiveFile0(int socketID, String path, long offset, long length, int block)
          Receive file.
static int selectEpoll(int epollId, IntBuffer readBuffer, IntBuffer writeBuffer, IntBuffer sizeBuffer, long millisTimeout)
          Basic access to UDT socket readiness selection feature.
 int send(byte[] array)
          send from byte[] array upto size=array.length bytes
 int send(byte[] array, int position, int limit)
          send from byte[] array upto size=limit-position bytes
 int send(ByteBuffer buffer)
          send from DirectByteBuffer, upto Buffer.remaining() bytes
protected static int send0(int socketID, int socketType, int timeToLive, boolean isOrdered, byte[] array)
          send from a complete byte[] array; wrapper for UDT::send(), UDT::sendmsg()
protected static int send1(int socketID, int socketType, int timeToLive, boolean isOrdered, byte[] array, int arayPosition, int arrayLimit)
          send from a portion of a byte[] array; wrapper for UDT::send(), UDT::sendmsg()
protected static int send2(int socketID, int socketType, int timeToLive, boolean isOrdered, ByteBuffer buffer, int bufferPosition, int bufferLimit)
          send from DirectByteBuffer; wrapper for UDT::send(), UDT::sendmsg()
 long sendFile(File file, long offset, long length)
          Send file to remote peer.
protected static long sendFile0(int socketID, String path, long offset, long length, int block)
          Send file.
 void setBlocking(boolean block)
          Configure socket in strict blocking / strict non-blocking mode.
 void setDefaultMessageSendMode()
          Apply default settings for message mode.
 void setMessageIsOdered(boolean isOrdered)
          default isOrdered value used by sendmsg mode
 void setMessageTimeTolLive(int timeToLive)
          default timeToLive value used by sendmsg mode
<T> void
setOption(OptionUDT<T> option, T value)
           
protected  void setOption0(int code, Class<?> klaz, Object value)
           
 void setReceiveBufferSize(int size)
          Set maximum receive buffer size.
 void setRendezvous(boolean isOn)
           
 void setReuseAddress(boolean on)
           
 void setSendBufferSize(int size)
          Set maximum send buffer size.
 void setSoLinger(boolean on, int linger)
           
 void setSoTimeout(int millisTimeout)
          call timeout (milliseconds); Set a timeout on blocking Socket operations: ServerSocket.accept(); SocketInputStream.read(); DatagramSocket.receive(); Enable/disable SO_TIMEOUT with the specified timeout, in milliseconds.
 StatusUDT status()
          returns native status of underlying native UDT socket
protected static void stopClass0()
          Call this before unloading native library.
protected static void testCrashJVM0()
           
protected static void testDirectByteBufferAccess0(ByteBuffer buffer)
           
protected static void testDirectIntBufferAccess0(IntBuffer buffer)
           
protected static void testDirectIntBufferLoad0(IntBuffer buffer)
           
protected static void testEmptyCall0()
           
protected static void testFillArray0(byte[] array)
           
protected static void testFillBuffer0(ByteBuffer buffer)
           
protected static void testGetSetArray0(int[] array, boolean isReturn)
           
protected static void testInvalidClose0(int socketID)
           
protected static void testIterateArray0(Object[] array)
           
protected static void testIterateSet0(Set<Object> set)
           
protected static int[] testMakeArray0(int size)
           
 String toString()
           
 String toStringMonitor()
          Show current monitor status.
 String toStringOptions()
          Show current socket options.
 TypeUDT type()
          message/stream socket type; read by JNI
 void updateMonitor(boolean makeClear)
          Load updated statistics values into monitor object.
protected  void updateMonitor0(boolean makeClear)
           
 
Methods inherited from class java.lang.Object
clone, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

DEFAULT_ACCEPT_QUEUE_SIZE

public static final int DEFAULT_ACCEPT_QUEUE_SIZE
Maximum number of connections queued in listening mode by accept()

See Also:
Constant Field Values

DEFAULT_FILE_BLOCK_SIZE

public static final int DEFAULT_FILE_BLOCK_SIZE
Block size used by sendFile(File, long, long)

See Also:
Constant Field Values

DEFAULT_MAX_SELECTOR_SIZE

public static final int DEFAULT_MAX_SELECTOR_SIZE
Maximum number sockets that can participate in a SelectorUDT.select() operation; see epoll.h to confirm current limit

See Also:
Constant Field Values

DEFAULT_MIN_SELECTOR_TIMEOUT

public static final int DEFAULT_MIN_SELECTOR_TIMEOUT
Minimum timeout of a SelectorUDT.select() operations.

See Also:
Constant Field Values

INFINITE_TTL

public static final int INFINITE_TTL
infinite message time to live;

See Also:
Constant Field Values

INIT_OK

@Native
public static boolean INIT_OK
Helper value that can be checked from CCC class and force JNI library load


log

protected static final org.slf4j.Logger log

SIGNATURE_JNI

@Native
public static final int SIGNATURE_JNI
JNI Signature that must match between java code and c++ code on all platforms; failure to match will abort native library load, as an indication of inconsistent build.

See Also:
Constant Field Values

TIMEOUT_INFINITE

public static final int TIMEOUT_INFINITE
infinite timeout:

blocking send/receive

epoll wait

See Also:
Constant Field Values

TIMEOUT_NONE

public static long TIMEOUT_NONE
zero timeout:

epoll wait


UDT_EXCEPT_INDEX

@Native
public static final int UDT_EXCEPT_INDEX
UDT::select() sizeArray/sizeBuffer index offset for EXCEPTION report

See Also:
Constant Field Values

UDT_READ_INDEX

@Native
public static final int UDT_READ_INDEX
UDT::select() sizeArray/sizeBuffer index offset for READ interest

See Also:
Constant Field Values

UDT_SIZE_COUNT

@Native
public static final int UDT_SIZE_COUNT
UDT::select() sizeArray/sizeBuffer size count or number of arrays/buffers

See Also:
Constant Field Values

UDT_WRITE_INDEX

@Native
public static final int UDT_WRITE_INDEX
UDT::select() sizeArray/sizeBuffer index offset for WRITE interest

See Also:
Constant Field Values
Constructor Detail

SocketUDT

public SocketUDT(TypeUDT type)
          throws ExceptionUDT
"Primary" socket. Default constructor; will apply setDefaultMessageSendMode()

Parameters:
type - UDT socket type
Throws:
ExceptionUDT

SocketUDT

protected SocketUDT(TypeUDT type,
                    int socketID)
             throws ExceptionUDT
"Secondary" socket. Made by accept0(), will apply setDefaultMessageSendMode()

Parameters:
socketID - UDT socket descriptor;
Throws:
ExceptionUDT
Method Detail

cleanup

public static void cleanup()
                    throws ExceptionUDT
Cleans up global JNI references and the UDT library.

The behavior of SocketUDT class after a call to cleanup is undefined, so it should only ever be called once you are done and you are ready for the class loader to unload the JNI library

Throws:
ExceptionUDT

epollAdd0

protected static void epollAdd0(int epollID,
                                int socketID,
                                int epollOpt)
                         throws ExceptionUDT
Throws:
ExceptionUDT
See Also:
UDT::epoll_add_usock()

epollCreate0

protected static int epollCreate0()
                           throws ExceptionUDT
Returns:
epoll id
Throws:
ExceptionUDT
See Also:
UDT::epoll_create()

epollRelease0

protected static void epollRelease0(int epollID)
                             throws ExceptionUDT
Throws:
ExceptionUDT
See Also:
UDT::epoll_release()

epollRemove0

protected static void epollRemove0(int epollID,
                                   int socketID)
                            throws ExceptionUDT
Throws:
ExceptionUDT
See Also:
UDT::epoll_remove_usock()

epollUpdate0

protected static void epollUpdate0(int epollID,
                                   int socketID,
                                   int epollMask)
                            throws ExceptionUDT
update epoll mask

Throws:
ExceptionUDT

epollVerify0

protected static int epollVerify0(int epollID,
                                  int socketID)
                           throws ExceptionUDT
query epoll mask

Throws:
ExceptionUDT

epollWait0

protected static int epollWait0(int epollID,
                                IntBuffer readBuffer,
                                IntBuffer writeBuffer,
                                IntBuffer sizeBuffer,
                                long millisTimeout)
                         throws ExceptionUDT
Throws:
ExceptionUDT
See Also:
UDT::epoll_wait()

getSignatureJNI0

protected static int getSignatureJNI0()
Verify that java code and c++ code builds are consistent.

See Also:
SIGNATURE_JNI

initClass0

protected static void initClass0()
                          throws ExceptionUDT
Call this after loading native library.

Throws:
ExceptionUDT
See Also:
UDT::startup()

receive0

protected static int receive0(int socketID,
                              int socketType,
                              byte[] array)
                       throws ExceptionUDT
receive into a complete byte array

Throws:
ExceptionUDT
See Also:
UDT::recv(), UDT::recvmsg()

receive1

protected static int receive1(int socketID,
                              int socketType,
                              byte[] array,
                              int position,
                              int limit)
                       throws ExceptionUDT
receive into a portion of a byte array

Throws:
ExceptionUDT
See Also:
UDT::recv(), UDT::recvmsg()

receive2

protected static int receive2(int socketID,
                              int socketType,
                              ByteBuffer buffer,
                              int position,
                              int limit)
                       throws ExceptionUDT
receive into a DirectByteBuffer

Throws:
ExceptionUDT
See Also:
UDT::recv(), UDT::recvmsg()

receiveFile0

protected static long receiveFile0(int socketID,
                                   String path,
                                   long offset,
                                   long length,
                                   int block)
                            throws ExceptionUDT
Receive file.

Throws:
ExceptionUDT
See Also:
UDT::recvfile

selectEpoll

public static int selectEpoll(int epollId,
                              IntBuffer readBuffer,
                              IntBuffer writeBuffer,
                              IntBuffer sizeBuffer,
                              long millisTimeout)
                       throws ExceptionUDT
Basic access to UDT socket readiness selection feature. Based on DirectIntBuffer info exchange.Timeout is in milliseconds.

Parameters:
millisTimeout - http://udt.sourceforge.net/udt4/doc/epoll.htm "Finally, for epoll_wait, negative timeout value will make the function to wait until an event happens. If the timeout value is 0, then the function returns immediately with any sockets associated an IO event. If timeout occurs before any event happens, the function returns 0".
Returns:
<0 : should not happen
=0 : timeout, no ready sockets
>0 : total number or reads, writes, exceptions
Throws:
ExceptionUDT
See Also:
epollWait0(int, IntBuffer, IntBuffer, IntBuffer, long)

send0

protected static int send0(int socketID,
                           int socketType,
                           int timeToLive,
                           boolean isOrdered,
                           byte[] array)
                    throws ExceptionUDT
send from a complete byte[] array; wrapper for UDT::send(), UDT::sendmsg()

Throws:
ExceptionUDT
See Also:
UDT::send(), UDT::sendmsg()

send1

protected static int send1(int socketID,
                           int socketType,
                           int timeToLive,
                           boolean isOrdered,
                           byte[] array,
                           int arayPosition,
                           int arrayLimit)
                    throws ExceptionUDT
send from a portion of a byte[] array; wrapper for UDT::send(), UDT::sendmsg()

Throws:
ExceptionUDT
See Also:
UDT::send(), UDT::sendmsg()

send2

protected static int send2(int socketID,
                           int socketType,
                           int timeToLive,
                           boolean isOrdered,
                           ByteBuffer buffer,
                           int bufferPosition,
                           int bufferLimit)
                    throws ExceptionUDT
send from DirectByteBuffer; wrapper for UDT::send(), UDT::sendmsg()

Throws:
ExceptionUDT
See Also:
UDT::send(), UDT::sendmsg()

sendFile0

protected static long sendFile0(int socketID,
                                String path,
                                long offset,
                                long length,
                                int block)
                         throws ExceptionUDT
Send file.

Throws:
ExceptionUDT
See Also:
UDT::sendfile

stopClass0

protected static void stopClass0()
                          throws ExceptionUDT
Call this before unloading native library.

Throws:
ExceptionUDT
See Also:
UDT::cleanup()

testCrashJVM0

protected static void testCrashJVM0()

testDirectByteBufferAccess0

protected static void testDirectByteBufferAccess0(ByteBuffer buffer)

testDirectIntBufferAccess0

protected static void testDirectIntBufferAccess0(IntBuffer buffer)

testDirectIntBufferLoad0

protected static void testDirectIntBufferLoad0(IntBuffer buffer)

testEmptyCall0

protected static void testEmptyCall0()

testFillArray0

protected static void testFillArray0(byte[] array)

testFillBuffer0

protected static void testFillBuffer0(ByteBuffer buffer)

testGetSetArray0

protected static void testGetSetArray0(int[] array,
                                       boolean isReturn)

testInvalidClose0

protected static void testInvalidClose0(int socketID)
                                 throws ExceptionUDT
Throws:
ExceptionUDT

testIterateArray0

protected static void testIterateArray0(Object[] array)

testIterateSet0

protected static void testIterateSet0(Set<Object> set)

testMakeArray0

protected static int[] testMakeArray0(int size)

accept

public SocketUDT accept()
                 throws ExceptionUDT
Returns:
null : no incoming connections (non-blocking mode only)
non null : newly accepted SocketUDT (both blocking and non-blocking)
Throws:
ExceptionUDT

accept0

protected SocketUDT accept0()
                     throws ExceptionUDT
Throws:
ExceptionUDT
See Also:
UDT::accept()

bind

public void bind(InetSocketAddress localSocketAddress)
          throws ExceptionUDT,
                 IllegalArgumentException
Throws:
ExceptionUDT
IllegalArgumentException

bind0

protected void bind0(InetSocketAddress localSocketAddress)
              throws ExceptionUDT
Throws:
ExceptionUDT
See Also:
UDT::bind()

clearError

public void clearError()
Clear error status on a socket, if any.

See Also:
UDT Error Handling

clearError0

protected void clearError0()
See Also:
UDT Error Handling

close

public void close()
           throws ExceptionUDT
Close socket if not already closed.

Throws:
ExceptionUDT
See Also:
close0()

close0

protected void close0()
               throws ExceptionUDT
Throws:
ExceptionUDT
See Also:
UDT::close()

connect

public void connect(InetSocketAddress remoteSocketAddress)
             throws ExceptionUDT
Connect to remote UDT socket.

Can be blocking or non blocking call; depending on OptionUDT.Is_Receive_Synchronous

Timing: UDT uses hard coded connect timeout:

normal socket: 3 seconds

rendezvous socket: 30 seconds; when OptionUDT.Is_Randezvous_Connect_Enabled is true

Throws:
ExceptionUDT
See Also:
connect0(InetSocketAddress)

connect0

protected void connect0(InetSocketAddress remoteSocketAddress)
                 throws ExceptionUDT
Throws:
ExceptionUDT
See Also:
UDT::connect()

equals

public boolean equals(Object otherSocketUDT)
Note: equality is based on socketID.

Overrides:
equals in class Object

finalize

protected void finalize()
NOTE: catch all exceptions; else prevents GC

NOTE: do not leak "this" references; else prevents GC

Overrides:
finalize in class Object

getError

public ErrorUDT getError()
Error object wrapper.

Returns:
error status set by last socket operation

getErrorCode

public int getErrorCode()
Error code set by last operation on a socket.

See Also:
UDT Error Handling

getErrorCode0

protected int getErrorCode0()
See Also:
UDT Error Handling

getErrorMessage

public String getErrorMessage()
Native error message set by last operation on a socket.

See Also:
t-error.htm

getErrorMessage0

protected String getErrorMessage0()
See Also:
UDT Error Handling

getListenQueueSize

public int getListenQueueSize()
See Also:
listen(int)

getLocalInetAddress

public InetAddress getLocalInetAddress()
Returns:
null : not bound
not null : valid address; result of bind(InetSocketAddress)

getLocalInetPort

public int getLocalInetPort()
Returns:
0 : not bound
>0 : valid port; result of bind(InetSocketAddress)

getLocalSocketAddress

public InetSocketAddress getLocalSocketAddress()
                                        throws ExceptionUDT
Returns:
null: not bound;
not null: local UDT socket address to which the the socket is bound
Throws:
ExceptionUDT
See Also:
hasLoadedLocalSocketAddress()

getMessageIsOdered

public boolean getMessageIsOdered()
default isOrdered value used by sendmsg mode

See Also:
UDT::sendmsg()

getMessageTimeTolLive

public int getMessageTimeTolLive()
default timeToLive value used by sendmsg mode

See Also:
UDT::sendmsg()

getOption

public <T> T getOption(OptionUDT<T> option)
            throws ExceptionUDT
Throws:
ExceptionUDT
See Also:
getOption0(int, Class)

getOption0

protected Object getOption0(int code,
                            Class<?> klaz)
                     throws ExceptionUDT
Throws:
ExceptionUDT
See Also:
UDT::getsockopt()

getReceiveBufferSize

public int getReceiveBufferSize()
                         throws ExceptionUDT
Get maximum receive buffer size. Reflects minimum of protocol-level (UDT) and kernel-level(UDP) settings.

Throws:
ExceptionUDT
See Also:
Socket.getReceiveBufferSize()

getRemoteInetAddress

public InetAddress getRemoteInetAddress()
Returns:
null : not connected
not null : valid address; result of connect(InetSocketAddress)

getRemoteInetPort

public int getRemoteInetPort()
Returns:
0 : not connected
>0 : valid port ; result of connect(InetSocketAddress)

getRemoteSocketAddress

public InetSocketAddress getRemoteSocketAddress()
                                         throws ExceptionUDT
Returns:
null : not connected;
not null: remote UDT peer socket address to which this socket is connected
Throws:
ExceptionUDT
See Also:
hasLoadedRemoteSocketAddress()

getReuseAddress

public boolean getReuseAddress()
                        throws ExceptionUDT
Check if local bind address is set to reuse mode.

Throws:
ExceptionUDT
See Also:
Socket.getReuseAddress()

getSendBufferSize

public int getSendBufferSize()
                      throws ExceptionUDT
Get maximum send buffer size. Reflects minimum of protocol-level (UDT) and kernel-level(UDP) settings.

Throws:
ExceptionUDT
See Also:
Socket.getSendBufferSize()

getSoLinger

public int getSoLinger()
                throws ExceptionUDT
Get time to linger on close (seconds).

Throws:
ExceptionUDT
See Also:
Socket.getSoLinger()

getSoTimeout

public int getSoTimeout()
                 throws ExceptionUDT
Get "any blocking operation" timeout setting. Returns milliseconds; zero return means "infinite"; negative means invalid

Throws:
ExceptionUDT
See Also:
Socket.getSoTimeout()

getStatus0

protected int getStatus0()
See Also:

hashCode

public int hashCode()
Note: uses socketID as hash code.

Overrides:
hashCode in class Object

hasLoadedLocalSocketAddress

protected boolean hasLoadedLocalSocketAddress()
Load localSocketAddress value.

See Also:
UDT::sockname()

hasLoadedRemoteSocketAddress

protected boolean hasLoadedRemoteSocketAddress()
Load remoteSocketAddress value.

See Also:
UDT::peername()

id

public int id()
native socket descriptor id; assigned by udt library


initInstance0

protected int initInstance0(int typeCode)
                     throws ExceptionUDT
used by default constructor

Throws:
ExceptionUDT

initInstance1

protected int initInstance1(int socketUDT)
                     throws ExceptionUDT
used by accept() internally

Throws:
ExceptionUDT

isBlocking

public boolean isBlocking()
Check if socket is in strict blocking mode. (JDK semantics)

Returns:
true : socket is valid and both send and receive are set to blocking mode; false : at least one channel is set to non-blocking mode or socket is invalid;
See Also:
isNonBlocking(), setBlocking(boolean)

isBound

public boolean isBound()
Check if socket is bound. (JDK semantics)

Returns:
true : bind(InetSocketAddress) was successful
false : otherwise

isClosed

public boolean isClosed()
Check if socket is closed. A convenience !isOpen();

See Also:
isOpen()

isConnected

public boolean isConnected()
Check if KindUDT.CONNECTOR socket is connected. (JDK semantics)

Returns:
true : connect(InetSocketAddress) was successful
false : otherwise

isNonBlocking

public boolean isNonBlocking()
Check if socket is in strict non-blocking mode.

Returns:
true : socket is valid and both send and receive are set to NON blocking mode; false : at least one channel is set to blocking mode or socket is invalid;
See Also:
isBlocking(), setBlocking(boolean)

isOpen

public boolean isOpen()
Check if socket is open. (JDK semantics). The status of underlying UDT socket is mapped into JDK expected categories

See Also:
StatusUDT

isRendezvous

public boolean isRendezvous()

listen

public void listen(int queueSize)
            throws ExceptionUDT
Parameters:
queueSize - maximum number of queued clients
Throws:
ExceptionUDT
See Also:
listen0(int)

listen0

protected void listen0(int queueSize)
                throws ExceptionUDT
Throws:
ExceptionUDT
See Also:
UDT::listen()

monitor

public MonitorUDT monitor()
performance monitor; updated by updateMonitor(boolean) in JNI

See Also:
updateMonitor(boolean)

receive

public int receive(byte[] array)
            throws ExceptionUDT
receive into byte[] array upto array.length bytes

Returns:
-1 : nothing received (non-blocking only)
=0 : timeout expired (blocking only)
>0 : normal receive, byte count
Throws:
ExceptionUDT
See Also:
receive0(int, int, byte[])

receive

public int receive(byte[] array,
                   int position,
                   int limit)
            throws ExceptionUDT
receive into byte[] array upto size=limit-position bytes

Returns:
-1 : nothing received (non-blocking only)
=0 : timeout expired (blocking only)
>0 : normal receive, byte count
Throws:
ExceptionUDT
See Also:
receive1(int, int, byte[], int, int)

receive

public int receive(ByteBuffer buffer)
            throws ExceptionUDT
receive into DirectByteBuffer; upto Buffer.remaining() bytes

Returns:
-1 : nothing received (non-blocking only)
=0 : timeout expired (blocking only)
>0 : normal receive, byte count
Throws:
ExceptionUDT
See Also:
receive2(int, int, ByteBuffer, int, int)

receiveFile

public long receiveFile(File file,
                        long offset,
                        long length)
                 throws ExceptionUDT
Receive file from remote peer.

Throws:
ExceptionUDT
See Also:
receiveFile0(int, String, long, long, int)

send

public int send(byte[] array)
         throws ExceptionUDT
send from byte[] array upto size=array.length bytes

Parameters:
array - array to send
Returns:
-1 : no buffer space (non-blocking only)
=0 : timeout expired (blocking only)
>0 : normal send, actual sent byte count
Throws:
ExceptionUDT
See Also:
send0(int, int, int, boolean, byte[])

send

public int send(byte[] array,
                int position,
                int limit)
         throws ExceptionUDT
send from byte[] array upto size=limit-position bytes

Parameters:
array - array to send
position - start of array portion to send
limit - finish of array portion to send
Returns:
-1 : no buffer space (non-blocking only)
=0 : timeout expired (blocking only)
>0 : normal send, actual sent byte count
Throws:
ExceptionUDT
See Also:
send1(int, int, int, boolean, byte[], int, int)

send

public int send(ByteBuffer buffer)
         throws ExceptionUDT
send from DirectByteBuffer, upto Buffer.remaining() bytes

Parameters:
buffer - buffer to send
Returns:
-1 : no buffer space (non-blocking only)
=0 : timeout expired (blocking only)
>0 : normal send, actual sent byte count
Throws:
ExceptionUDT
See Also:
send2(int, int, int, boolean, ByteBuffer, int, int)

sendFile

public long sendFile(File file,
                     long offset,
                     long length)
              throws ExceptionUDT
Send file to remote peer.

Throws:
ExceptionUDT
See Also:
sendFile0(int, String, long, long, int)

setBlocking

public void setBlocking(boolean block)
                 throws ExceptionUDT
Configure socket in strict blocking / strict non-blocking mode.

Parameters:
block - true : set both send and receive to blocking mode; false : set both send and receive to non-blocking mode
Throws:
ExceptionUDT
See Also:
AbstractSelectableChannel.configureBlocking(boolean)

setDefaultMessageSendMode

public void setDefaultMessageSendMode()
Apply default settings for message mode.

IsOdered = true;
TimeTolLive = INFINITE_TTL;


setMessageIsOdered

public void setMessageIsOdered(boolean isOrdered)
default isOrdered value used by sendmsg mode

See Also:
UDT::sendmsg()

setMessageTimeTolLive

public void setMessageTimeTolLive(int timeToLive)
default timeToLive value used by sendmsg mode

See Also:
UDT::sendmsg()

setOption

public <T> void setOption(OptionUDT<T> option,
                          T value)
               throws ExceptionUDT
Throws:
ExceptionUDT
See Also:
setOption0(int, Class, Object)

setOption0

protected void setOption0(int code,
                          Class<?> klaz,
                          Object value)
                   throws ExceptionUDT
Throws:
ExceptionUDT
See Also:
UDT::setsockopt()

setReceiveBufferSize

public void setReceiveBufferSize(int size)
                          throws ExceptionUDT
Set maximum receive buffer size. Affects both protocol-level (UDT) and kernel-level(UDP) settings.

Throws:
ExceptionUDT

setRendezvous

public void setRendezvous(boolean isOn)
                   throws ExceptionUDT
Throws:
ExceptionUDT

setReuseAddress

public void setReuseAddress(boolean on)
                     throws ExceptionUDT
Throws:
ExceptionUDT

setSendBufferSize

public void setSendBufferSize(int size)
                       throws ExceptionUDT
Set maximum send buffer size. Affects both protocol-level (UDT) and kernel-level(UDP) settings

Throws:
ExceptionUDT
See Also:
Socket.setSendBufferSize(int)

setSoLinger

public void setSoLinger(boolean on,
                        int linger)
                 throws ExceptionUDT
Throws:
ExceptionUDT

setSoTimeout

public void setSoTimeout(int millisTimeout)
                  throws ExceptionUDT
call timeout (milliseconds); Set a timeout on blocking Socket operations: ServerSocket.accept(); SocketInputStream.read(); DatagramSocket.receive(); Enable/disable SO_TIMEOUT with the specified timeout, in milliseconds. A timeout of zero is interpreted as an infinite timeout.

Throws:
ExceptionUDT

status

public StatusUDT status()
returns native status of underlying native UDT socket


toString

public String toString()
Overrides:
toString in class Object

toStringMonitor

public String toStringMonitor()
Show current monitor status.


toStringOptions

public String toStringOptions()
Show current socket options.


type

public TypeUDT type()
message/stream socket type; read by JNI


updateMonitor

public void updateMonitor(boolean makeClear)
                   throws ExceptionUDT
Load updated statistics values into monitor object. Must call this methos only on connected socket.

Parameters:
makeClear - true : reset all statistics with this call; false : keep collecting statistics, load updated values.
Throws:
ExceptionUDT
See Also:
updateMonitor0(boolean)

updateMonitor0

protected void updateMonitor0(boolean makeClear)
                       throws ExceptionUDT
Throws:
ExceptionUDT
See Also:
UDT::perfmon

barchart-udt-core
2.3.0-SNAPSHOT / 2013-05-13T01:37:38.485-0500

Copyright © 2009-2013 Barchart, Inc.. All Rights Reserved.