Getting UDT to properly load from eclipse/idea/natively
This commit is contained in:
parent
a35935ff85
commit
e961f395a5
@ -27,7 +27,7 @@ import java.util.Set;
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* UDT native socket wrapper
|
* UDT native socket wrapper
|
||||||
* <p>
|
* <p/>
|
||||||
* note: current implementation supports IPv4 only (no IPv6)
|
* note: current implementation supports IPv4 only (no IPv6)
|
||||||
*/
|
*/
|
||||||
public
|
public
|
||||||
@ -77,20 +77,20 @@ class SocketUDT {
|
|||||||
* indication of inconsistent build.
|
* indication of inconsistent build.
|
||||||
*/
|
*/
|
||||||
@Native
|
@Native
|
||||||
public static final int SIGNATURE_JNI = 20130512; // VersionUDT.BUILDTIME;
|
public static final int SIGNATURE_JNI = 20150706; // VersionUDT.BUILDTIME;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* infinite timeout:
|
* infinite timeout:
|
||||||
* <p>
|
* <p/>
|
||||||
* blocking send/receive
|
* blocking send/receive
|
||||||
* <p>
|
* <p/>
|
||||||
* epoll wait
|
* epoll wait
|
||||||
*/
|
*/
|
||||||
public static final int TIMEOUT_INFINITE = -1;
|
public static final int TIMEOUT_INFINITE = -1;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* zero timeout:
|
* zero timeout:
|
||||||
* <p>
|
* <p/>
|
||||||
* epoll wait
|
* epoll wait
|
||||||
*/
|
*/
|
||||||
public static long TIMEOUT_NONE = 0;
|
public static long TIMEOUT_NONE = 0;
|
||||||
@ -133,7 +133,7 @@ class SocketUDT {
|
|||||||
Method nativeMethod = exitClass.getMethod("isNative");
|
Method nativeMethod = exitClass.getMethod("isNative");
|
||||||
Object invoke = nativeMethod.invoke(null);
|
Object invoke = nativeMethod.invoke(null);
|
||||||
if (invoke != null) {
|
if (invoke != null) {
|
||||||
isNativeDeployed = (boolean) invoke;
|
isNativeDeployed = (Boolean) invoke;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (Throwable t) {
|
} catch (Throwable t) {
|
||||||
@ -144,7 +144,13 @@ class SocketUDT {
|
|||||||
final Logger logger = LoggerFactory.getLogger(SocketUDT.class);
|
final Logger logger = LoggerFactory.getLogger(SocketUDT.class);
|
||||||
|
|
||||||
String moduleDir = System.getProperty("user.dir");
|
String moduleDir = System.getProperty("user.dir");
|
||||||
final String libraryDir = FileUtil.normalizeAsFile(moduleDir + "../../../dorkbox/Dorkbox-Network/natives");
|
String libraryDir = FileUtil.getParentRelativeToDir(moduleDir, "dorkbox");
|
||||||
|
File file = new File(libraryDir);
|
||||||
|
if (file.getName()
|
||||||
|
.equals("dorkbox")) {
|
||||||
|
file = file.getParentFile();
|
||||||
|
}
|
||||||
|
libraryDir = FileUtil.normalizeAsFile(file.getAbsolutePath() + "/dorkbox/dorkbox/Dorkbox-Network/natives");
|
||||||
|
|
||||||
|
|
||||||
if (libraryDir == null || libraryDir.length() == 0) {
|
if (libraryDir == null || libraryDir.length() == 0) {
|
||||||
@ -192,12 +198,15 @@ class SocketUDT {
|
|||||||
INIT_OK = true;
|
INIT_OK = true;
|
||||||
|
|
||||||
log.debug("native library load & init OK");
|
log.debug("native library load & init OK");
|
||||||
|
}
|
||||||
|
|
||||||
|
public static
|
||||||
|
void init() {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Cleans up global JNI references and the UDT library.
|
* Cleans up global JNI references and the UDT library.
|
||||||
* <p>
|
* <p/>
|
||||||
* The behavior of SocketUDT class after a call to cleanup is undefined, so
|
* 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
|
* it should only ever be called once you are done and you are ready for the
|
||||||
* class loader to unload the JNI library
|
* class loader to unload the JNI library
|
||||||
@ -211,7 +220,7 @@ class SocketUDT {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @see <a
|
* @see <a
|
||||||
* href="http://udt.sourceforge.net/udt4/doc/epoll.htm">UDT::epoll_add_usock()</a>
|
* href="http://udt.sourceforge.net/udt4/doc/epoll.htm">UDT::epoll_add_usock()</a>
|
||||||
*/
|
*/
|
||||||
protected static native
|
protected static native
|
||||||
void epollAdd0( //
|
void epollAdd0( //
|
||||||
@ -222,23 +231,22 @@ class SocketUDT {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @return epoll id
|
* @return epoll id
|
||||||
*
|
|
||||||
* @see <a
|
* @see <a
|
||||||
* href="http://udt.sourceforge.net/udt4/doc/epoll.htm">UDT::epoll_create()</a>
|
* href="http://udt.sourceforge.net/udt4/doc/epoll.htm">UDT::epoll_create()</a>
|
||||||
*/
|
*/
|
||||||
protected static native
|
protected static native
|
||||||
int epollCreate0() throws ExceptionUDT;
|
int epollCreate0() throws ExceptionUDT;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see <a
|
* @see <a
|
||||||
* href="http://udt.sourceforge.net/udt4/doc/epoll.htm">UDT::epoll_release()</a>
|
* href="http://udt.sourceforge.net/udt4/doc/epoll.htm">UDT::epoll_release()</a>
|
||||||
*/
|
*/
|
||||||
protected static native
|
protected static native
|
||||||
void epollRelease0(final int epollID) throws ExceptionUDT;
|
void epollRelease0(final int epollID) throws ExceptionUDT;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see <a
|
* @see <a
|
||||||
* href="http://udt.sourceforge.net/udt4/doc/epoll.htm">UDT::epoll_remove_usock()</a>
|
* href="http://udt.sourceforge.net/udt4/doc/epoll.htm">UDT::epoll_remove_usock()</a>
|
||||||
*/
|
*/
|
||||||
protected static native
|
protected static native
|
||||||
void epollRemove0( //
|
void epollRemove0( //
|
||||||
@ -258,9 +266,10 @@ class SocketUDT {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @see <a
|
* @see <a
|
||||||
* href="http://udt.sourceforge.net/udt4/doc/epoll.htm">UDT::epoll_wait()</a>
|
* href="http://udt.sourceforge.net/udt4/doc/epoll.htm">UDT::epoll_wait()</a>
|
||||||
*/
|
*/
|
||||||
protected static native
|
protected static native
|
||||||
|
int epollWait0( //
|
||||||
int epollWait0( //
|
int epollWait0( //
|
||||||
final int epollID, //
|
final int epollID, //
|
||||||
final IntBuffer readBuffer, //
|
final IntBuffer readBuffer, //
|
||||||
@ -280,7 +289,7 @@ class SocketUDT {
|
|||||||
* Call this after loading native library.
|
* Call this after loading native library.
|
||||||
*
|
*
|
||||||
* @see <a
|
* @see <a
|
||||||
* href="http://udt.sourceforge.net/udt4/doc/startup.htm">UDT::startup()</a>
|
* href="http://udt.sourceforge.net/udt4/doc/startup.htm">UDT::startup()</a>
|
||||||
*/
|
*/
|
||||||
protected static native
|
protected static native
|
||||||
void initClass0() throws ExceptionUDT;
|
void initClass0() throws ExceptionUDT;
|
||||||
@ -289,9 +298,9 @@ class SocketUDT {
|
|||||||
* receive into a complete byte array
|
* receive into a complete byte array
|
||||||
*
|
*
|
||||||
* @see <a
|
* @see <a
|
||||||
* href="http://udt.sourceforge.net/udt4/doc/recv.htm">UDT::recv()</a>
|
* href="http://udt.sourceforge.net/udt4/doc/recv.htm">UDT::recv()</a>
|
||||||
* @see <a
|
* @see <a
|
||||||
* href="http://udt.sourceforge.net/udt4/doc/recv.htm">UDT::recvmsg()</a>
|
* href="http://udt.sourceforge.net/udt4/doc/recv.htm">UDT::recvmsg()</a>
|
||||||
*/
|
*/
|
||||||
protected static native
|
protected static native
|
||||||
int receive0(//
|
int receive0(//
|
||||||
@ -304,9 +313,9 @@ class SocketUDT {
|
|||||||
* receive into a portion of a byte array
|
* receive into a portion of a byte array
|
||||||
*
|
*
|
||||||
* @see <a
|
* @see <a
|
||||||
* href="http://udt.sourceforge.net/udt4/doc/recv.htm">UDT::recv()</a>
|
* href="http://udt.sourceforge.net/udt4/doc/recv.htm">UDT::recv()</a>
|
||||||
* @see <a
|
* @see <a
|
||||||
* href="http://udt.sourceforge.net/udt4/doc/recv.htm">UDT::recvmsg()</a>
|
* href="http://udt.sourceforge.net/udt4/doc/recv.htm">UDT::recvmsg()</a>
|
||||||
*/
|
*/
|
||||||
protected static native
|
protected static native
|
||||||
int receive1( //
|
int receive1( //
|
||||||
@ -321,9 +330,9 @@ class SocketUDT {
|
|||||||
* receive into a {@link java.nio.channels.DirectByteBuffer}
|
* receive into a {@link java.nio.channels.DirectByteBuffer}
|
||||||
*
|
*
|
||||||
* @see <a
|
* @see <a
|
||||||
* href="http://udt.sourceforge.net/udt4/doc/recv.htm">UDT::recv()</a>
|
* href="http://udt.sourceforge.net/udt4/doc/recv.htm">UDT::recv()</a>
|
||||||
* @see <a
|
* @see <a
|
||||||
* href="http://udt.sourceforge.net/udt4/doc/recv.htm">UDT::recvmsg()</a>
|
* href="http://udt.sourceforge.net/udt4/doc/recv.htm">UDT::recvmsg()</a>
|
||||||
*/
|
*/
|
||||||
protected static native
|
protected static native
|
||||||
int receive2( //
|
int receive2( //
|
||||||
@ -338,7 +347,7 @@ class SocketUDT {
|
|||||||
* Receive file.
|
* Receive file.
|
||||||
*
|
*
|
||||||
* @see <a
|
* @see <a
|
||||||
* href="http://udt.sourceforge.net/udt4/doc/sendfile.htm">UDT::recvfile</a>
|
* href="http://udt.sourceforge.net/udt4/doc/sendfile.htm">UDT::recvfile</a>
|
||||||
*/
|
*/
|
||||||
protected static native
|
protected static native
|
||||||
long receiveFile0( //
|
long receiveFile0( //
|
||||||
@ -354,21 +363,16 @@ class SocketUDT {
|
|||||||
* {@link java.nio.DirectIntBuffer} info exchange.Timeout is in
|
* {@link java.nio.DirectIntBuffer} info exchange.Timeout is in
|
||||||
* milliseconds.
|
* milliseconds.
|
||||||
*
|
*
|
||||||
* @param millisTimeout
|
* @param millisTimeout http://udt.sourceforge.net/udt4/doc/epoll.htm
|
||||||
*
|
* <p/>
|
||||||
* 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
|
||||||
* "Finally, for epoll_wait, negative timeout value will make the
|
* is 0, then the function returns immediately with any sockets
|
||||||
* function to wait until an event happens. If the timeout value
|
* associated an IO event. If timeout occurs before any event
|
||||||
* is 0, then the function returns immediately with any sockets
|
* happens, the function returns 0".
|
||||||
* associated an IO event. If timeout occurs before any event
|
|
||||||
* happens, the function returns 0".
|
|
||||||
*
|
|
||||||
*
|
|
||||||
* @return <code><0</code> : should not happen<br>
|
* @return <code><0</code> : should not happen<br>
|
||||||
* <code>=0</code> : timeout, no ready sockets<br>
|
* <code>=0</code> : timeout, no ready sockets<br>
|
||||||
* <code>>0</code> : total number or reads, writes, exceptions<br>
|
* <code>>0</code> : total number or reads, writes, exceptions<br>
|
||||||
*
|
|
||||||
* @see #epollWait0(int, IntBuffer, IntBuffer, IntBuffer, long)
|
* @see #epollWait0(int, IntBuffer, IntBuffer, IntBuffer, long)
|
||||||
*/
|
*/
|
||||||
public static
|
public static
|
||||||
@ -397,13 +401,13 @@ class SocketUDT {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* send from a complete byte[] array;
|
* send from a complete byte[] array;
|
||||||
*
|
* <p/>
|
||||||
* wrapper for <em>UDT::send()</em>, <em>UDT::sendmsg()</em>
|
* wrapper for <em>UDT::send()</em>, <em>UDT::sendmsg()</em>
|
||||||
*
|
*
|
||||||
* @see <a
|
* @see <a
|
||||||
* href="http://udt.sourceforge.net/udt4/doc/send.htm">UDT::send()</a>
|
* href="http://udt.sourceforge.net/udt4/doc/send.htm">UDT::send()</a>
|
||||||
* @see <a
|
* @see <a
|
||||||
* href="http://udt.sourceforge.net/udt4/doc/sendmsg.htm">UDT::sendmsg()</a>
|
* href="http://udt.sourceforge.net/udt4/doc/sendmsg.htm">UDT::sendmsg()</a>
|
||||||
*/
|
*/
|
||||||
protected static native
|
protected static native
|
||||||
int send0( //
|
int send0( //
|
||||||
@ -416,13 +420,13 @@ class SocketUDT {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* send from a portion of a byte[] array;
|
* send from a portion of a byte[] array;
|
||||||
*
|
* <p/>
|
||||||
* wrapper for <em>UDT::send()</em>, <em>UDT::sendmsg()</em>
|
* wrapper for <em>UDT::send()</em>, <em>UDT::sendmsg()</em>
|
||||||
*
|
*
|
||||||
* @see <a
|
* @see <a
|
||||||
* href="http://udt.sourceforge.net/udt4/doc/send.htm">UDT::send()</a>
|
* href="http://udt.sourceforge.net/udt4/doc/send.htm">UDT::send()</a>
|
||||||
* @see <a
|
* @see <a
|
||||||
* href="http://udt.sourceforge.net/udt4/doc/sendmsg.htm">UDT::sendmsg()</a>
|
* href="http://udt.sourceforge.net/udt4/doc/sendmsg.htm">UDT::sendmsg()</a>
|
||||||
*/
|
*/
|
||||||
protected static native
|
protected static native
|
||||||
int send1( //
|
int send1( //
|
||||||
@ -437,13 +441,13 @@ class SocketUDT {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* send from {@link java.nio.DirectByteBuffer};
|
* send from {@link java.nio.DirectByteBuffer};
|
||||||
*
|
* <p/>
|
||||||
* wrapper for <em>UDT::send()</em>, <em>UDT::sendmsg()</em>
|
* wrapper for <em>UDT::send()</em>, <em>UDT::sendmsg()</em>
|
||||||
*
|
*
|
||||||
* @see <a
|
* @see <a
|
||||||
* href="http://udt.sourceforge.net/udt4/doc/send.htm">UDT::send()</a>
|
* href="http://udt.sourceforge.net/udt4/doc/send.htm">UDT::send()</a>
|
||||||
* @see <a
|
* @see <a
|
||||||
* href="http://udt.sourceforge.net/udt4/doc/sendmsg.htm">UDT::sendmsg()</a>
|
* href="http://udt.sourceforge.net/udt4/doc/sendmsg.htm">UDT::sendmsg()</a>
|
||||||
*/
|
*/
|
||||||
protected static native
|
protected static native
|
||||||
int send2( //
|
int send2( //
|
||||||
@ -460,7 +464,7 @@ class SocketUDT {
|
|||||||
* Send file.
|
* Send file.
|
||||||
*
|
*
|
||||||
* @see <a
|
* @see <a
|
||||||
* href="http://udt.sourceforge.net/udt4/doc/sendfile.htm">UDT::sendfile</a>
|
* href="http://udt.sourceforge.net/udt4/doc/sendfile.htm">UDT::sendfile</a>
|
||||||
*/
|
*/
|
||||||
protected static native
|
protected static native
|
||||||
long sendFile0( //
|
long sendFile0( //
|
||||||
@ -475,7 +479,7 @@ class SocketUDT {
|
|||||||
* Call this before unloading native library.
|
* Call this before unloading native library.
|
||||||
*
|
*
|
||||||
* @see <a
|
* @see <a
|
||||||
* href="http://udt.sourceforge.net/udt4/doc/cleanup.htm.htm">UDT::cleanup()</a>
|
* href="http://udt.sourceforge.net/udt4/doc/cleanup.htm.htm">UDT::cleanup()</a>
|
||||||
*/
|
*/
|
||||||
protected static native
|
protected static native
|
||||||
void stopClass0() throws ExceptionUDT;
|
void stopClass0() throws ExceptionUDT;
|
||||||
@ -560,7 +564,7 @@ class SocketUDT {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* native address family; read by JNI
|
* native address family; read by JNI
|
||||||
* <p>
|
* <p/>
|
||||||
* TODO add support for AF_INET6
|
* TODO add support for AF_INET6
|
||||||
*/
|
*/
|
||||||
@Native
|
@Native
|
||||||
@ -581,8 +585,7 @@ class SocketUDT {
|
|||||||
* "Primary" socket. Default constructor; will apply
|
* "Primary" socket. Default constructor; will apply
|
||||||
* {@link #setDefaultMessageSendMode()}
|
* {@link #setDefaultMessageSendMode()}
|
||||||
*
|
*
|
||||||
* @param type
|
* @param type UDT socket type
|
||||||
* UDT socket type
|
|
||||||
*/
|
*/
|
||||||
public
|
public
|
||||||
SocketUDT(final TypeUDT type) throws ExceptionUDT {
|
SocketUDT(final TypeUDT type) throws ExceptionUDT {
|
||||||
@ -600,8 +603,7 @@ class SocketUDT {
|
|||||||
* "Secondary" socket. Made by {@link #accept0()}, will apply
|
* "Secondary" socket. Made by {@link #accept0()}, will apply
|
||||||
* {@link #setDefaultMessageSendMode()}
|
* {@link #setDefaultMessageSendMode()}
|
||||||
*
|
*
|
||||||
* @param socketID
|
* @param socketID UDT socket descriptor;
|
||||||
* UDT socket descriptor;
|
|
||||||
*/
|
*/
|
||||||
protected
|
protected
|
||||||
SocketUDT(final TypeUDT type, final int socketID) throws ExceptionUDT {
|
SocketUDT(final TypeUDT type, final int socketID) throws ExceptionUDT {
|
||||||
@ -617,8 +619,8 @@ class SocketUDT {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @return null : no incoming connections (non-blocking mode only)<br>
|
* @return null : no incoming connections (non-blocking mode only)<br>
|
||||||
* non null : newly accepted SocketUDT (both blocking and
|
* non null : newly accepted SocketUDT (both blocking and
|
||||||
* non-blocking)<br>
|
* non-blocking)<br>
|
||||||
*/
|
*/
|
||||||
public
|
public
|
||||||
SocketUDT accept() throws ExceptionUDT {
|
SocketUDT accept() throws ExceptionUDT {
|
||||||
@ -627,7 +629,7 @@ class SocketUDT {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @see <a
|
* @see <a
|
||||||
* href="http://udt.sourceforge.net/udt4/doc/accept.htm">UDT::accept()</a>
|
* href="http://udt.sourceforge.net/udt4/doc/accept.htm">UDT::accept()</a>
|
||||||
*/
|
*/
|
||||||
protected native
|
protected native
|
||||||
SocketUDT accept0() throws ExceptionUDT;
|
SocketUDT accept0() throws ExceptionUDT;
|
||||||
@ -641,7 +643,7 @@ class SocketUDT {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @see <a
|
* @see <a
|
||||||
* href="http://udt.sourceforge.net/udt4/doc/bind.htm">UDT::bind()</a>
|
* href="http://udt.sourceforge.net/udt4/doc/bind.htm">UDT::bind()</a>
|
||||||
*/
|
*/
|
||||||
protected native
|
protected native
|
||||||
void bind0(final InetSocketAddress localSocketAddress) throws ExceptionUDT;
|
void bind0(final InetSocketAddress localSocketAddress) throws ExceptionUDT;
|
||||||
@ -650,7 +652,7 @@ class SocketUDT {
|
|||||||
* Clear error status on a socket, if any.
|
* Clear error status on a socket, if any.
|
||||||
*
|
*
|
||||||
* @see <a href="http://udt.sourceforge.net/udt4/doc/t-error.htm">UDT Error
|
* @see <a href="http://udt.sourceforge.net/udt4/doc/t-error.htm">UDT Error
|
||||||
* Handling</a>
|
* Handling</a>
|
||||||
*/
|
*/
|
||||||
public
|
public
|
||||||
void clearError() {
|
void clearError() {
|
||||||
@ -659,7 +661,7 @@ class SocketUDT {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @see <a href="http://udt.sourceforge.net/udt4/doc/t-error.htm">UDT Error
|
* @see <a href="http://udt.sourceforge.net/udt4/doc/t-error.htm">UDT Error
|
||||||
* Handling</a>
|
* Handling</a>
|
||||||
*/
|
*/
|
||||||
protected native
|
protected native
|
||||||
void clearError0();
|
void clearError0();
|
||||||
@ -709,28 +711,28 @@ class SocketUDT {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @see <a
|
* @see <a
|
||||||
* href="http://udt.sourceforge.net/udt4/doc/close.htm">UDT::close()</a>
|
* href="http://udt.sourceforge.net/udt4/doc/close.htm">UDT::close()</a>
|
||||||
*/
|
*/
|
||||||
protected native
|
protected native
|
||||||
void flush0() throws ExceptionUDT;
|
void flush0() throws ExceptionUDT;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see <a
|
* @see <a
|
||||||
* href="http://udt.sourceforge.net/udt4/doc/close.htm">UDT::close()</a>
|
* href="http://udt.sourceforge.net/udt4/doc/close.htm">UDT::close()</a>
|
||||||
*/
|
*/
|
||||||
protected native
|
protected native
|
||||||
void close0() throws ExceptionUDT;
|
void close0() throws ExceptionUDT;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Connect to remote UDT socket.
|
* Connect to remote UDT socket.
|
||||||
* <p>
|
* <p/>
|
||||||
* Can be blocking or non blocking call; depending on
|
* Can be blocking or non blocking call; depending on
|
||||||
* {@link OptionUDT#Is_Receive_Synchronous}
|
* {@link OptionUDT#Is_Receive_Synchronous}
|
||||||
* <p>
|
* <p/>
|
||||||
* Timing: UDT uses hard coded connect timeout:
|
* Timing: UDT uses hard coded connect timeout:
|
||||||
* <p>
|
* <p/>
|
||||||
* normal socket: 3 seconds
|
* normal socket: 3 seconds
|
||||||
* <p>
|
* <p/>
|
||||||
* rendezvous socket: 30 seconds; when
|
* rendezvous socket: 30 seconds; when
|
||||||
* {@link OptionUDT#Is_Randezvous_Connect_Enabled} is true
|
* {@link OptionUDT#Is_Randezvous_Connect_Enabled} is true
|
||||||
*
|
*
|
||||||
@ -745,7 +747,7 @@ class SocketUDT {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @see <a
|
* @see <a
|
||||||
* href="http://udt.sourceforge.net/udt4/doc/connect.htm">UDT::connect()</a>
|
* href="http://udt.sourceforge.net/udt4/doc/connect.htm">UDT::connect()</a>
|
||||||
*/
|
*/
|
||||||
protected native
|
protected native
|
||||||
void connect0(final InetSocketAddress remoteSocketAddress) throws ExceptionUDT;
|
void connect0(final InetSocketAddress remoteSocketAddress) throws ExceptionUDT;
|
||||||
@ -765,7 +767,7 @@ class SocketUDT {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* NOTE: catch all exceptions; else prevents GC
|
* NOTE: catch all exceptions; else prevents GC
|
||||||
* <p>
|
* <p/>
|
||||||
* NOTE: do not leak "this" references; else prevents GC
|
* NOTE: do not leak "this" references; else prevents GC
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
@ -794,7 +796,7 @@ class SocketUDT {
|
|||||||
* Error code set by last operation on a socket.
|
* Error code set by last operation on a socket.
|
||||||
*
|
*
|
||||||
* @see <a href="http://udt.sourceforge.net/udt4/doc/t-error.htm">UDT Error
|
* @see <a href="http://udt.sourceforge.net/udt4/doc/t-error.htm">UDT Error
|
||||||
* Handling</a>
|
* Handling</a>
|
||||||
*/
|
*/
|
||||||
public
|
public
|
||||||
int getErrorCode() {
|
int getErrorCode() {
|
||||||
@ -803,7 +805,7 @@ class SocketUDT {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @see <a href="http://udt.sourceforge.net/udt4/doc/t-error.htm">UDT Error
|
* @see <a href="http://udt.sourceforge.net/udt4/doc/t-error.htm">UDT Error
|
||||||
* Handling</a>
|
* Handling</a>
|
||||||
*/
|
*/
|
||||||
protected native
|
protected native
|
||||||
int getErrorCode0();
|
int getErrorCode0();
|
||||||
@ -812,7 +814,7 @@ class SocketUDT {
|
|||||||
* Native error message set by last operation on a socket.
|
* Native error message set by last operation on a socket.
|
||||||
*
|
*
|
||||||
* @see <a
|
* @see <a
|
||||||
* href="http://udt.sourceforge.net/udt4/doc/t-error.htm">t-error.htm</a>
|
* href="http://udt.sourceforge.net/udt4/doc/t-error.htm">t-error.htm</a>
|
||||||
*/
|
*/
|
||||||
public
|
public
|
||||||
String getErrorMessage() {
|
String getErrorMessage() {
|
||||||
@ -821,7 +823,7 @@ class SocketUDT {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @see <a href="http://udt.sourceforge.net/udt4/doc/t-error.htm">UDT Error
|
* @see <a href="http://udt.sourceforge.net/udt4/doc/t-error.htm">UDT Error
|
||||||
* Handling</a>
|
* Handling</a>
|
||||||
*/
|
*/
|
||||||
protected native
|
protected native
|
||||||
String getErrorMessage0();
|
String getErrorMessage0();
|
||||||
@ -836,8 +838,8 @@ class SocketUDT {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @return null : not bound<br>
|
* @return null : not bound<br>
|
||||||
* not null : valid address; result of
|
* not null : valid address; result of
|
||||||
* {@link #bind(InetSocketAddress)}<br>
|
* {@link #bind(InetSocketAddress)}<br>
|
||||||
*/
|
*/
|
||||||
public
|
public
|
||||||
InetAddress getLocalInetAddress() {
|
InetAddress getLocalInetAddress() {
|
||||||
@ -857,7 +859,7 @@ class SocketUDT {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @return 0 : not bound<br>
|
* @return 0 : not bound<br>
|
||||||
* >0 : valid port; result of {@link #bind(InetSocketAddress)}<br>
|
* >0 : valid port; result of {@link #bind(InetSocketAddress)}<br>
|
||||||
*/
|
*/
|
||||||
public
|
public
|
||||||
int getLocalInetPort() {
|
int getLocalInetPort() {
|
||||||
@ -877,8 +879,8 @@ class SocketUDT {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @return null: not bound; <br>
|
* @return null: not bound; <br>
|
||||||
* not null: local UDT socket address to which the the socket is
|
* not null: local UDT socket address to which the the socket is
|
||||||
* bound<br>
|
* bound<br>
|
||||||
* @see #hasLoadedLocalSocketAddress()
|
* @see #hasLoadedLocalSocketAddress()
|
||||||
*/
|
*/
|
||||||
public
|
public
|
||||||
@ -895,7 +897,7 @@ class SocketUDT {
|
|||||||
* default isOrdered value used by sendmsg mode
|
* default isOrdered value used by sendmsg mode
|
||||||
*
|
*
|
||||||
* @see <a
|
* @see <a
|
||||||
* href="http://udt.sourceforge.net/udt4/doc/sendmsg.htm">UDT::sendmsg()</a>
|
* href="http://udt.sourceforge.net/udt4/doc/sendmsg.htm">UDT::sendmsg()</a>
|
||||||
*/
|
*/
|
||||||
public
|
public
|
||||||
boolean getMessageIsOdered() {
|
boolean getMessageIsOdered() {
|
||||||
@ -906,7 +908,7 @@ class SocketUDT {
|
|||||||
* default timeToLive value used by sendmsg mode
|
* default timeToLive value used by sendmsg mode
|
||||||
*
|
*
|
||||||
* @see <a
|
* @see <a
|
||||||
* href="http://udt.sourceforge.net/udt4/doc/sendmsg.htm">UDT::sendmsg()</a>
|
* href="http://udt.sourceforge.net/udt4/doc/sendmsg.htm">UDT::sendmsg()</a>
|
||||||
*/
|
*/
|
||||||
public
|
public
|
||||||
int getMessageTimeTolLive() {
|
int getMessageTimeTolLive() {
|
||||||
@ -930,7 +932,7 @@ class SocketUDT {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @see <a
|
* @see <a
|
||||||
* href="http://udt.sourceforge.net/udt4/doc/opt.htm">UDT::getsockopt()</a>
|
* href="http://udt.sourceforge.net/udt4/doc/opt.htm">UDT::getsockopt()</a>
|
||||||
*/
|
*/
|
||||||
protected native
|
protected native
|
||||||
Object getOption0(final int code, final Class<?> klaz) throws ExceptionUDT;
|
Object getOption0(final int code, final Class<?> klaz) throws ExceptionUDT;
|
||||||
@ -952,8 +954,8 @@ class SocketUDT {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @return null : not connected<br>
|
* @return null : not connected<br>
|
||||||
* not null : valid address; result of
|
* not null : valid address; result of
|
||||||
* {@link #connect(InetSocketAddress)}<br>
|
* {@link #connect(InetSocketAddress)}<br>
|
||||||
*/
|
*/
|
||||||
public
|
public
|
||||||
InetAddress getRemoteInetAddress() {
|
InetAddress getRemoteInetAddress() {
|
||||||
@ -973,7 +975,7 @@ class SocketUDT {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @return 0 : not connected<br>
|
* @return 0 : not connected<br>
|
||||||
* >0 : valid port ; result of {@link #connect(InetSocketAddress)}<br>
|
* >0 : valid port ; result of {@link #connect(InetSocketAddress)}<br>
|
||||||
*/
|
*/
|
||||||
public
|
public
|
||||||
int getRemoteInetPort() {
|
int getRemoteInetPort() {
|
||||||
@ -993,8 +995,8 @@ class SocketUDT {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @return null : not connected; <br>
|
* @return null : not connected; <br>
|
||||||
* not null: remote UDT peer socket address to which this socket is
|
* not null: remote UDT peer socket address to which this socket is
|
||||||
* connected <br>
|
* connected <br>
|
||||||
* @see #hasLoadedRemoteSocketAddress()
|
* @see #hasLoadedRemoteSocketAddress()
|
||||||
*/
|
*/
|
||||||
public
|
public
|
||||||
@ -1042,7 +1044,7 @@ class SocketUDT {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Get "any blocking operation" timeout setting.
|
* Get "any blocking operation" timeout setting.
|
||||||
*
|
* <p/>
|
||||||
* Returns milliseconds; zero return means "infinite"; negative means
|
* Returns milliseconds; zero return means "infinite"; negative means
|
||||||
* invalid
|
* invalid
|
||||||
*
|
*
|
||||||
@ -1096,7 +1098,7 @@ class SocketUDT {
|
|||||||
* Load {@link #localSocketAddress} value.
|
* Load {@link #localSocketAddress} value.
|
||||||
*
|
*
|
||||||
* @see <a
|
* @see <a
|
||||||
* href="http://udt.sourceforge.net/udt4/doc/sockname.htm">UDT::sockname()</a>
|
* href="http://udt.sourceforge.net/udt4/doc/sockname.htm">UDT::sockname()</a>
|
||||||
*/
|
*/
|
||||||
protected native
|
protected native
|
||||||
boolean hasLoadedLocalSocketAddress();
|
boolean hasLoadedLocalSocketAddress();
|
||||||
@ -1105,7 +1107,7 @@ class SocketUDT {
|
|||||||
* Load {@link #remoteSocketAddress} value.
|
* Load {@link #remoteSocketAddress} value.
|
||||||
*
|
*
|
||||||
* @see <a
|
* @see <a
|
||||||
* href="http://udt.sourceforge.net/udt4/doc/peername.htm">UDT::peername()</a>
|
* href="http://udt.sourceforge.net/udt4/doc/peername.htm">UDT::peername()</a>
|
||||||
*/
|
*/
|
||||||
protected native
|
protected native
|
||||||
boolean hasLoadedRemoteSocketAddress();
|
boolean hasLoadedRemoteSocketAddress();
|
||||||
@ -1134,9 +1136,8 @@ class SocketUDT {
|
|||||||
* Check if socket is in strict blocking mode. (JDK semantics)
|
* Check if socket is in strict blocking mode. (JDK semantics)
|
||||||
*
|
*
|
||||||
* @return true : socket is valid and both send and receive are set to
|
* @return true : socket is valid and both send and receive are set to
|
||||||
* blocking mode; false : at least one channel is set to
|
* blocking mode; false : at least one channel is set to
|
||||||
* non-blocking mode or socket is invalid;
|
* non-blocking mode or socket is invalid;
|
||||||
*
|
|
||||||
* @see #isNonBlocking()
|
* @see #isNonBlocking()
|
||||||
* @see #setBlocking(boolean)
|
* @see #setBlocking(boolean)
|
||||||
*/
|
*/
|
||||||
@ -1158,7 +1159,7 @@ class SocketUDT {
|
|||||||
* Check if socket is bound. (JDK semantics)
|
* Check if socket is bound. (JDK semantics)
|
||||||
*
|
*
|
||||||
* @return true : {@link #bind(InetSocketAddress)} was successful<br>
|
* @return true : {@link #bind(InetSocketAddress)} was successful<br>
|
||||||
* false : otherwise<br>
|
* false : otherwise<br>
|
||||||
*/
|
*/
|
||||||
public
|
public
|
||||||
boolean isBound() {
|
boolean isBound() {
|
||||||
@ -1187,7 +1188,7 @@ class SocketUDT {
|
|||||||
* Check if {@link KindUDT#CONNECTOR} socket is connected. (JDK semantics)
|
* Check if {@link KindUDT#CONNECTOR} socket is connected. (JDK semantics)
|
||||||
*
|
*
|
||||||
* @return true : {@link #connect(InetSocketAddress)} was successful<br>
|
* @return true : {@link #connect(InetSocketAddress)} was successful<br>
|
||||||
* false : otherwise<br>
|
* false : otherwise<br>
|
||||||
*/
|
*/
|
||||||
public
|
public
|
||||||
boolean isConnected() {
|
boolean isConnected() {
|
||||||
@ -1203,8 +1204,8 @@ class SocketUDT {
|
|||||||
* Check if socket is in strict non-blocking mode.
|
* Check if socket is in strict non-blocking mode.
|
||||||
*
|
*
|
||||||
* @return true : socket is valid and both send and receive are set to NON
|
* @return true : socket is valid and both send and receive are set to NON
|
||||||
* blocking mode; false : at least one channel is set to blocking
|
* blocking mode; false : at least one channel is set to blocking
|
||||||
* mode or socket is invalid;
|
* mode or socket is invalid;
|
||||||
* @see #isBlocking()
|
* @see #isBlocking()
|
||||||
* @see #setBlocking(boolean)
|
* @see #setBlocking(boolean)
|
||||||
*/
|
*/
|
||||||
@ -1255,9 +1256,7 @@ class SocketUDT {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param queueSize
|
* @param queueSize maximum number of queued clients
|
||||||
* maximum number of queued clients
|
|
||||||
*
|
|
||||||
* @see #listen0(int)
|
* @see #listen0(int)
|
||||||
*/
|
*/
|
||||||
public
|
public
|
||||||
@ -1271,7 +1270,7 @@ class SocketUDT {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @see <a
|
* @see <a
|
||||||
* href="http://udt.sourceforge.net/udt4/doc/listen.htm">UDT::listen()</a>
|
* href="http://udt.sourceforge.net/udt4/doc/listen.htm">UDT::listen()</a>
|
||||||
*/
|
*/
|
||||||
protected native
|
protected native
|
||||||
void listen0(final int queueSize) throws ExceptionUDT;
|
void listen0(final int queueSize) throws ExceptionUDT;
|
||||||
@ -1290,8 +1289,8 @@ class SocketUDT {
|
|||||||
* receive into byte[] array upto <code>array.length</code> bytes
|
* receive into byte[] array upto <code>array.length</code> bytes
|
||||||
*
|
*
|
||||||
* @return <code>-1</code> : nothing received (non-blocking only)<br>
|
* @return <code>-1</code> : nothing received (non-blocking only)<br>
|
||||||
* <code>=0</code> : timeout expired (blocking only)<br>
|
* <code>=0</code> : timeout expired (blocking only)<br>
|
||||||
* <code>>0</code> : normal receive, byte count<br>
|
* <code>>0</code> : normal receive, byte count<br>
|
||||||
* @see #receive0(int, int, byte[])
|
* @see #receive0(int, int, byte[])
|
||||||
*/
|
*/
|
||||||
public
|
public
|
||||||
@ -1307,8 +1306,8 @@ class SocketUDT {
|
|||||||
* receive into byte[] array upto <code>size=limit-position</code> bytes
|
* receive into byte[] array upto <code>size=limit-position</code> bytes
|
||||||
*
|
*
|
||||||
* @return <code>-1</code> : nothing received (non-blocking only)<br>
|
* @return <code>-1</code> : nothing received (non-blocking only)<br>
|
||||||
* <code>=0</code> : timeout expired (blocking only)<br>
|
* <code>=0</code> : timeout expired (blocking only)<br>
|
||||||
* <code>>0</code> : normal receive, byte count<br>
|
* <code>>0</code> : normal receive, byte count<br>
|
||||||
* @see #receive1(int, int, byte[], int, int)
|
* @see #receive1(int, int, byte[], int, int)
|
||||||
*/
|
*/
|
||||||
public
|
public
|
||||||
@ -1325,8 +1324,8 @@ class SocketUDT {
|
|||||||
* {@link ByteBuffer#remaining()} bytes
|
* {@link ByteBuffer#remaining()} bytes
|
||||||
*
|
*
|
||||||
* @return <code>-1</code> : nothing received (non-blocking only)<br>
|
* @return <code>-1</code> : nothing received (non-blocking only)<br>
|
||||||
* <code>=0</code> : timeout expired (blocking only)<br>
|
* <code>=0</code> : timeout expired (blocking only)<br>
|
||||||
* <code>>0</code> : normal receive, byte count<br>
|
* <code>>0</code> : normal receive, byte count<br>
|
||||||
* @see #receive2(int, int, ByteBuffer, int, int)
|
* @see #receive2(int, int, ByteBuffer, int, int)
|
||||||
*/
|
*/
|
||||||
public
|
public
|
||||||
@ -1403,11 +1402,10 @@ class SocketUDT {
|
|||||||
/**
|
/**
|
||||||
* send from byte[] array upto <code>size=array.length</code> bytes
|
* send from byte[] array upto <code>size=array.length</code> bytes
|
||||||
*
|
*
|
||||||
* @param array
|
* @param array array to send
|
||||||
* array to send
|
|
||||||
* @return <code>-1</code> : no buffer space (non-blocking only) <br>
|
* @return <code>-1</code> : no buffer space (non-blocking only) <br>
|
||||||
* <code>=0</code> : timeout expired (blocking only) <br>
|
* <code>=0</code> : timeout expired (blocking only) <br>
|
||||||
* <code>>0</code> : normal send, actual sent byte count <br>
|
* <code>>0</code> : normal send, actual sent byte count <br>
|
||||||
* @see #send0(int, int, int, boolean, byte[])
|
* @see #send0(int, int, int, boolean, byte[])
|
||||||
*/
|
*/
|
||||||
public
|
public
|
||||||
@ -1428,15 +1426,12 @@ class SocketUDT {
|
|||||||
/**
|
/**
|
||||||
* send from byte[] array upto <code>size=limit-position</code> bytes
|
* send from byte[] array upto <code>size=limit-position</code> bytes
|
||||||
*
|
*
|
||||||
* @param array
|
* @param array array to send
|
||||||
* array to send
|
* @param position start of array portion to send
|
||||||
* @param position
|
* @param limit finish of array portion to send
|
||||||
* start of array portion to send
|
|
||||||
* @param limit
|
|
||||||
* finish of array portion to send
|
|
||||||
* @return <code>-1</code> : no buffer space (non-blocking only) <br>
|
* @return <code>-1</code> : no buffer space (non-blocking only) <br>
|
||||||
* <code>=0</code> : timeout expired (blocking only) <br>
|
* <code>=0</code> : timeout expired (blocking only) <br>
|
||||||
* <code>>0</code> : normal send, actual sent byte count <br>
|
* <code>>0</code> : normal send, actual sent byte count <br>
|
||||||
* @see #send1(int, int, int, boolean, byte[], int, int)
|
* @see #send1(int, int, int, boolean, byte[], int, int)
|
||||||
*/
|
*/
|
||||||
public
|
public
|
||||||
@ -1464,11 +1459,10 @@ class SocketUDT {
|
|||||||
* send from {@link java.nio.DirectByteBuffer}, upto
|
* send from {@link java.nio.DirectByteBuffer}, upto
|
||||||
* {@link ByteBuffer#remaining()} bytes
|
* {@link ByteBuffer#remaining()} bytes
|
||||||
*
|
*
|
||||||
* @param buffer
|
* @param buffer buffer to send
|
||||||
* buffer to send
|
|
||||||
* @return <code>-1</code> : no buffer space (non-blocking only)<br>
|
* @return <code>-1</code> : no buffer space (non-blocking only)<br>
|
||||||
* <code>=0</code> : timeout expired (blocking only)<br>
|
* <code>=0</code> : timeout expired (blocking only)<br>
|
||||||
* <code>>0</code> : normal send, actual sent byte count<br>
|
* <code>>0</code> : normal send, actual sent byte count<br>
|
||||||
* @see #send2(int, int, int, boolean, ByteBuffer, int, int)
|
* @see #send2(int, int, int, boolean, ByteBuffer, int, int)
|
||||||
*/
|
*/
|
||||||
public
|
public
|
||||||
@ -1551,9 +1545,8 @@ class SocketUDT {
|
|||||||
/**
|
/**
|
||||||
* Configure socket in strict blocking / strict non-blocking mode.
|
* Configure socket in strict blocking / strict non-blocking mode.
|
||||||
*
|
*
|
||||||
* @param block
|
* @param block true : set both send and receive to blocking mode; false : set
|
||||||
* true : set both send and receive to blocking mode; false : set
|
* both send and receive to non-blocking mode
|
||||||
* both send and receive to non-blocking mode
|
|
||||||
* @see java.nio.channels.SocketChannel#configureBlocking(boolean)
|
* @see java.nio.channels.SocketChannel#configureBlocking(boolean)
|
||||||
*/
|
*/
|
||||||
public
|
public
|
||||||
@ -1570,7 +1563,7 @@ class SocketUDT {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Apply default settings for message mode.
|
* Apply default settings for message mode.
|
||||||
* <p>
|
* <p/>
|
||||||
* IsOdered = true;<br>
|
* IsOdered = true;<br>
|
||||||
* TimeTolLive = INFINITE_TTL;<br>
|
* TimeTolLive = INFINITE_TTL;<br>
|
||||||
*/
|
*/
|
||||||
@ -1584,7 +1577,7 @@ class SocketUDT {
|
|||||||
* default isOrdered value used by sendmsg mode
|
* default isOrdered value used by sendmsg mode
|
||||||
*
|
*
|
||||||
* @see <a
|
* @see <a
|
||||||
* href="http://udt.sourceforge.net/udt4/doc/sendmsg.htm">UDT::sendmsg()</a>
|
* href="http://udt.sourceforge.net/udt4/doc/sendmsg.htm">UDT::sendmsg()</a>
|
||||||
*/
|
*/
|
||||||
public
|
public
|
||||||
void setMessageIsOdered(final boolean isOrdered) {
|
void setMessageIsOdered(final boolean isOrdered) {
|
||||||
@ -1595,7 +1588,7 @@ class SocketUDT {
|
|||||||
* default timeToLive value used by sendmsg mode
|
* default timeToLive value used by sendmsg mode
|
||||||
*
|
*
|
||||||
* @see <a
|
* @see <a
|
||||||
* href="http://udt.sourceforge.net/udt4/doc/sendmsg.htm">UDT::sendmsg()</a>
|
* href="http://udt.sourceforge.net/udt4/doc/sendmsg.htm">UDT::sendmsg()</a>
|
||||||
*/
|
*/
|
||||||
public
|
public
|
||||||
void setMessageTimeTolLive(final int timeToLive) {
|
void setMessageTimeTolLive(final int timeToLive) {
|
||||||
@ -1621,7 +1614,7 @@ class SocketUDT {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @see <a
|
* @see <a
|
||||||
* href="http://udt.sourceforge.net/udt4/doc/opt.htm">UDT::setsockopt()</a>
|
* href="http://udt.sourceforge.net/udt4/doc/opt.htm">UDT::setsockopt()</a>
|
||||||
*/
|
*/
|
||||||
protected native
|
protected native
|
||||||
void setOption0( //
|
void setOption0( //
|
||||||
@ -1768,9 +1761,8 @@ class SocketUDT {
|
|||||||
* Load updated statistics values into {@link #monitor} object. Must call
|
* Load updated statistics values into {@link #monitor} object. Must call
|
||||||
* this methos only on connected socket.
|
* this methos only on connected socket.
|
||||||
*
|
*
|
||||||
* @param makeClear
|
* @param makeClear true : reset all statistics with this call; false : keep
|
||||||
* true : reset all statistics with this call; false : keep
|
* collecting statistics, load updated values.
|
||||||
* collecting statistics, load updated values.
|
|
||||||
* @see #updateMonitor0(boolean)
|
* @see #updateMonitor0(boolean)
|
||||||
*/
|
*/
|
||||||
public
|
public
|
||||||
@ -1780,7 +1772,7 @@ class SocketUDT {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @see <a
|
* @see <a
|
||||||
* href="http://udt.sourceforge.net/udt4/doc/trace.htm">UDT::perfmon</a>
|
* href="http://udt.sourceforge.net/udt4/doc/trace.htm">UDT::perfmon</a>
|
||||||
*/
|
*/
|
||||||
protected native
|
protected native
|
||||||
void updateMonitor0(final boolean makeClear) throws ExceptionUDT;
|
void updateMonitor0(final boolean makeClear) throws ExceptionUDT;
|
||||||
|
@ -1,92 +1,93 @@
|
|||||||
/**
|
/**
|
||||||
* Copyright (C) 2009-2013 Barchart, Inc. <http://www.barchart.com/>
|
* Copyright (C) 2009-2013 Barchart, Inc. <http://www.barchart.com/>
|
||||||
*
|
* <p/>
|
||||||
* All rights reserved. Licensed under the OSI BSD License.
|
* All rights reserved. Licensed under the OSI BSD License.
|
||||||
*
|
* <p/>
|
||||||
* http://www.opensource.org/licenses/bsd-license.php
|
* http://www.opensource.org/licenses/bsd-license.php
|
||||||
*/
|
*/
|
||||||
package com.barchart.udt.net;
|
package com.barchart.udt.net;
|
||||||
|
|
||||||
|
import com.barchart.udt.ErrorUDT;
|
||||||
|
import com.barchart.udt.SocketUDT;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.OutputStream;
|
import java.io.OutputStream;
|
||||||
import java.nio.channels.IllegalBlockingModeException;
|
import java.nio.channels.IllegalBlockingModeException;
|
||||||
|
|
||||||
import com.barchart.udt.ErrorUDT;
|
|
||||||
import com.barchart.udt.SocketUDT;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* {@link OutputStream} for UDT sockets.
|
* {@link OutputStream} for UDT sockets.
|
||||||
*/
|
*/
|
||||||
public class NetOutputStreamUDT extends OutputStream {
|
public
|
||||||
|
class NetOutputStreamUDT extends OutputStream {
|
||||||
|
|
||||||
protected final SocketUDT socketUDT;
|
protected final SocketUDT socketUDT;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
* @param socketUDT The UDT socket.
|
||||||
* @param socketUDT
|
*/
|
||||||
* The UDT socket.
|
public
|
||||||
*/
|
NetOutputStreamUDT(final SocketUDT socketUDT) {
|
||||||
public NetOutputStreamUDT(final SocketUDT socketUDT) {
|
|
||||||
|
|
||||||
if (!socketUDT.isBlocking()) {
|
if (!socketUDT.isBlocking()) {
|
||||||
throw new IllegalBlockingModeException();
|
throw new IllegalBlockingModeException();
|
||||||
}
|
}
|
||||||
|
|
||||||
this.socketUDT = socketUDT;
|
this.socketUDT = socketUDT;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void write(final int b) throws IOException {
|
public
|
||||||
|
void write(final int b) throws IOException {
|
||||||
|
|
||||||
// Just cast it -- this is the same thing SocketOutputStream does.
|
// Just cast it -- this is the same thing SocketOutputStream does.
|
||||||
final byte[] bytes = { (byte) b };
|
final byte[] bytes = {(byte) b};
|
||||||
|
|
||||||
write(bytes);
|
write(bytes);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void write(final byte[] bytes) throws IOException {
|
public
|
||||||
|
void write(final byte[] bytes) throws IOException {
|
||||||
|
|
||||||
write(bytes, 0, bytes.length);
|
write(bytes, 0, bytes.length);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void write(final byte[] bytes, final int off, final int len)
|
public
|
||||||
throws IOException {
|
void write(final byte[] bytes, final int off, final int len) throws IOException {
|
||||||
|
|
||||||
int bytesRemaining = len;
|
int bytesRemaining = len;
|
||||||
|
|
||||||
while (bytesRemaining > 0) {
|
while (bytesRemaining > 0) {
|
||||||
|
|
||||||
final int count = socketUDT.send(bytes, off + len - bytesRemaining,
|
final int count = socketUDT.send(bytes, off + len - bytesRemaining, off + len);
|
||||||
off + len);
|
|
||||||
|
|
||||||
if (count > 0) {
|
if (count > 0) {
|
||||||
bytesRemaining -= count;
|
bytesRemaining -= count;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (count == 0) {
|
if (count == 0) {
|
||||||
throw new ExceptionSendUDT(socketUDT.id(),
|
throw new ExceptionSendUDT(socketUDT.id(), ErrorUDT.USER_DEFINED_MESSAGE, "UDT send time out");
|
||||||
ErrorUDT.USER_DEFINED_MESSAGE, "UDT send time out");
|
}
|
||||||
}
|
|
||||||
|
|
||||||
throw new IllegalStateException(
|
throw new IllegalStateException("Socket has been changed to non-blocking");
|
||||||
"Socket has been chaged to non-blocking");
|
}
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void close() throws IOException {
|
public
|
||||||
socketUDT.close();
|
void close() throws IOException {
|
||||||
}
|
socketUDT.close();
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void flush() throws IOException {
|
public
|
||||||
socketUDT.flush();
|
void flush() throws IOException {
|
||||||
}
|
socketUDT.flush();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user