@Override protected int setPlatformSocketOption(int sockfd, int level, int optName, TCPSocketOptions opt, Integer optVal, int optSize) throws NativeErrorException { try { return setsockopt(sockfd, level, optName, new IntByReference(optVal.intValue()), optSize); } catch (LastErrorException le) { throw new NativeErrorException(le.getMessage(), le.getErrorCode(), le.getCause()); } }
@Override protected int setPlatformSocketOption(int sockfd, int level, int optName, TCPSocketOptions opt, Integer optVal, int optSize) throws NativeErrorException { try { switch (optName) { case OPT_TCP_KEEPALIVE_THRESHOLD: // value required is in millis final IntByReference timeout = new IntByReference(optVal.intValue() * 1000); int result = setsockopt(sockfd, level, optName, timeout, optSize); if (result == 0) { // setting ABORT_THRESHOLD to be same as KEEPALIVE_THRESHOLD return setsockopt(sockfd, level, OPT_TCP_KEEPALIVE_ABORT_THRESHOLD, timeout, optSize); } else { return result; } default: throw new UnsupportedOperationException("unsupported option " + opt); } } catch (LastErrorException le) { throw new NativeErrorException(le.getMessage(), le.getErrorCode(), le.getCause()); } }
new NativeErrorException(le.getMessage(), le.getErrorCode(), le.getCause())); } else { final SocketException se =
@Override protected int setPlatformSocketOption(int sockfd, int level, int optName, TCPSocketOptions opt, Integer optVal, int optSize) throws NativeErrorException { try { return setsockopt(sockfd, level, optName, new IntByReference(optVal.intValue()), optSize); } catch (LastErrorException le) { throw new NativeErrorException(le.getMessage(), le.getErrorCode(), le.getCause()); } }
@Override protected int setPlatformSocketOption(int sockfd, int level, int optName, TCPSocketOptions opt, Integer optVal, int optSize) throws NativeErrorException { try { switch (optName) { case OPT_TCP_KEEPALIVE_THRESHOLD: // value required is in millis final IntByReference timeout = new IntByReference( optVal.intValue() * 1000); int result = setsockopt(sockfd, level, optName, timeout, optSize); if (result == 0) { // setting ABORT_THRESHOLD to be same as KEEPALIVE_THRESHOLD return setsockopt(sockfd, level, OPT_TCP_KEEPALIVE_ABORT_THRESHOLD, timeout, optSize); } else { return result; } default: throw new UnsupportedOperationException("unsupported option " + opt); } } catch (LastErrorException le) { throw new NativeErrorException(le.getMessage(), le.getErrorCode(), le.getCause()); } }
getUnsupportedSocketOptionMessage(errorOpt), new NativeErrorException(le.getMessage(), le.getErrorCode(), le.getCause()));
public void connect(SocketAddress endpoint, int timeout) throws IOException { try { is = new SharedMemoryInputStream(); os = new SharedMemoryOutputStream(); String prefix = memoryName + "_" + getConnectNumber(); clientRead = openEvent(prefix + "_CLIENT_READ"); serverRead = openEvent(prefix + "_SERVER_READ"); serverWrote = openEvent(prefix + "_SERVER_WROTE"); clientWrote = openEvent(prefix + "_CLIENT_WROTE"); connectionClosed = openEvent(prefix + "_CONNECTION_CLOSED"); view = mapMemory(prefix + "_DATA", Kernel32.FILE_MAP_WRITE, BUFFERLEN); Kernel32.INSTANCE.SetEvent(serverRead); } catch (LastErrorException lee) { throw new IOException(lee.getMessage(), lee.getCause()); } }
public void connect(SocketAddress endpoint, int timeout) throws IOException { try { is = new SharedMemoryInputStream(); os = new SharedMemoryOutputStream(); String prefix = memoryName + "_" + getConnectNumber(); clientRead = openEvent(prefix + "_CLIENT_READ"); serverRead = openEvent(prefix + "_SERVER_READ"); serverWrote = openEvent(prefix + "_SERVER_WROTE"); clientWrote = openEvent(prefix + "_CLIENT_WROTE"); connectionClosed = openEvent(prefix + "_CONNECTION_CLOSED"); view = mapMemory(prefix + "_DATA", Kernel32.FILE_MAP_WRITE, BUFFERLEN); Kernel32.INSTANCE.SetEvent(serverRead); } catch (LastErrorException lee) { throw new IOException(lee.getMessage(), lee.getCause()); } }