static <T> T getSocketOption(int fd, SocketOption<?> name) throws IOException { jnr.constants.platform.SocketOption optname = rMap.get(name); if (null == optname) { throw new AssertionError("Option not found"); } Class<?> type = name.type(); if (type == Credentials.class) { return (T) Credentials.getCredentials(fd); } if (type == Integer.class) { return (T) Integer.valueOf(Native.getsockopt(fd, SocketLevel.SOL_SOCKET, optname.intValue())); } return (T) Boolean.valueOf(Native.getboolsockopt(fd, SocketLevel.SOL_SOCKET, optname.intValue())); }