MCPcopy Index your code
hub / github.com/questdb/questdb / Net

Class Net

core/src/main/java/io/questdb/network/Net.java:44–465  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

42import static io.questdb.std.Files.toOsFd;
43
44public final class Net {
45
46 @SuppressWarnings("unused")
47 public static final int EOTHERDISCONNECT = -2;
48 @SuppressWarnings("unused")
49 public static final int EPEERDISCONNECT = -1;
50 @SuppressWarnings("unused")
51 public static final int ERETRY = 0;
52 public static final int EWOULDBLOCK;
53 public static final long MMSGHDR_BUFFER_ADDRESS_OFFSET;
54 public static final long MMSGHDR_BUFFER_LENGTH_OFFSET;
55 public static final long MMSGHDR_SIZE;
56 public static final int SHUT_WR = 1;
57 private static final AtomicInteger ADDR_INFO_COUNTER = new AtomicInteger();
58 private static final Log LOG = LogFactory.getLog(Net.class);
59 private static final AtomicInteger SOCK_ADDR_COUNTER = new AtomicInteger();
60 // TCP KeepAlive not meant to be configurable. It's a last resort measure to disable/change keepalive if the default
61 // value causes problems in some environments. If it does not cause problems then this option should be removed after a few releases.
62 // It's not exposed as PropertyKey, because it would become a supported and hard to remove API.
63 private static final int TCP_KEEPALIVE_SECONDS = Integer.getInteger("questdb.unsupported.tcp.keepalive.seconds", 30);
64
65 private Net() {
66 }
67
68 /**
69 * Aborts blocking accept() call. On Darwin and Windows
70 * this method simply closes the underlying file descriptor.
71 * On Linux this method calls shutdown().
72 * <p>
73 * Once accept() exists it is by convention liable for
74 * closing its own file descriptor.
75 *
76 * @param fd file descriptor
77 * @return 0 when call was successful and -1 otherwise. In case of
78 * error errno() would return error code.
79 */
80 public static int abortAccept(long fd) {
81 return abortAccept(toOsFd(fd));
82 }
83
84 public static long accept(long serverFd) {
85 return Files.createUniqueFd(accept0(toOsFd(serverFd)));
86 }
87
88 public static void appendIP4(CharSink<?> sink, long ip) {
89 sink.put((ip >> 24) & 0xff).putAscii('.')
90 .put((ip >> 16) & 0xff).putAscii('.')
91 .put((ip >> 8) & 0xff).putAscii('.')
92 .put(ip & 0xff);
93 }
94
95 public static boolean bindTcp(long fd, int ipv4address, int port) {
96 return bindTcp(toOsFd(fd), ipv4address, port);
97 }
98
99 public static boolean bindTcp(long fd, CharSequence ipv4address, int port) {
100 return bindTcp(fd, parseIPv4(ipv4address), port);
101 }

Callers

nothing calls this directly

Calls 7

getLogMethod · 0.95
initMethod · 0.95
getEwouldblockMethod · 0.95
isLinuxMethod · 0.95
getMsgHeaderSizeMethod · 0.95

Tested by

no test coverage detected