BsdSocket Class — netty Architecture
Architecture documentation for the BsdSocket class in BsdSocket.java from the netty codebase.
Entity Profile
Dependency Diagram
graph TD fa698263_65bd_2717_1cc3_a912a3159bf5["BsdSocket"] 31301f31_a32a_23ac_2960_a4c991df2dae["BsdSocket.java"] fa698263_65bd_2717_1cc3_a912a3159bf5 -->|defined in| 31301f31_a32a_23ac_2960_a4c991df2dae fb3c3cb7_9de5_cb33_c4bb_12480c65dbbc["BsdSocket()"] fa698263_65bd_2717_1cc3_a912a3159bf5 -->|method| fb3c3cb7_9de5_cb33_c4bb_12480c65dbbc c1d21e0b_98ec_71d1_d775_01f2172a667f["setAcceptFilter()"] fa698263_65bd_2717_1cc3_a912a3159bf5 -->|method| c1d21e0b_98ec_71d1_d775_01f2172a667f f450510a_c234_21ee_d796_3dae7f9ca09c["setTcpNoPush()"] fa698263_65bd_2717_1cc3_a912a3159bf5 -->|method| f450510a_c234_21ee_d796_3dae7f9ca09c bf5c4366_ce12_1f95_9551_2436c30e1a2f["setSndLowAt()"] fa698263_65bd_2717_1cc3_a912a3159bf5 -->|method| bf5c4366_ce12_1f95_9551_2436c30e1a2f ed6dbc41_c563_4bec_81cf_37db4695b5a3["setTcpFastOpen()"] fa698263_65bd_2717_1cc3_a912a3159bf5 -->|method| ed6dbc41_c563_4bec_81cf_37db4695b5a3 5a854dc5_2fab_8cdf_069e_b035b5f10f86["isTcpNoPush()"] fa698263_65bd_2717_1cc3_a912a3159bf5 -->|method| 5a854dc5_2fab_8cdf_069e_b035b5f10f86 9e0a715b_b7d6_95ae_24af_07eb42fc2af5["getSndLowAt()"] fa698263_65bd_2717_1cc3_a912a3159bf5 -->|method| 9e0a715b_b7d6_95ae_24af_07eb42fc2af5 8b9630c6_ca2c_6373_53d7_d5da7b5c8639["AcceptFilter()"] fa698263_65bd_2717_1cc3_a912a3159bf5 -->|method| 8b9630c6_ca2c_6373_53d7_d5da7b5c8639 cd08d6fa_2bae_1f89_6481_b5dd1b66e7e5["isTcpFastOpen()"] fa698263_65bd_2717_1cc3_a912a3159bf5 -->|method| cd08d6fa_2bae_1f89_6481_b5dd1b66e7e5 6ec3bb9c_14ab_3c35_64d5_10ceb688acca["PeerCredentials()"] fa698263_65bd_2717_1cc3_a912a3159bf5 -->|method| 6ec3bb9c_14ab_3c35_64d5_10ceb688acca 7514e479_8852_71ef_ec25_c7f13c707239["sendFile()"] fa698263_65bd_2717_1cc3_a912a3159bf5 -->|method| 7514e479_8852_71ef_ec25_c7f13c707239 94aad4a9_4d21_8b46_bfad_738e9d7b7bbb["connectx()"] fa698263_65bd_2717_1cc3_a912a3159bf5 -->|method| 94aad4a9_4d21_8b46_bfad_738e9d7b7bbb d12100c2_d950_8487_f809_97cbe339b8ff["getAcceptFilter()"] fa698263_65bd_2717_1cc3_a912a3159bf5 -->|method| d12100c2_d950_8487_f809_97cbe339b8ff
Relationship Graph
Source Code
transport-classes-kqueue/src/main/java/io/netty/channel/kqueue/BsdSocket.java lines 40–270
final class BsdSocket extends Socket {
// These limits are just based on observations. I couldn't find anything in header files which formally
// define these limits.
private static final int APPLE_SND_LOW_AT_MAX = 1 << 17;
private static final int FREEBSD_SND_LOW_AT_MAX = 1 << 15;
static final int BSD_SND_LOW_AT_MAX = Math.min(APPLE_SND_LOW_AT_MAX, FREEBSD_SND_LOW_AT_MAX);
/**
* The `endpoints` structure passed to `connectx(2)` has an optional "source interface" field,
* which is the index of the network interface to use.
* According to `if_nametoindex(3)`, the value 0 is used when no interface is specified.
*/
private static final int UNSPECIFIED_SOURCE_INTERFACE = 0;
BsdSocket(int fd) {
super(fd);
}
void setAcceptFilter(AcceptFilter acceptFilter) throws IOException {
setAcceptFilter(intValue(), acceptFilter.filterName(), acceptFilter.filterArgs());
}
void setTcpNoPush(boolean tcpNoPush) throws IOException {
setTcpNoPush(intValue(), tcpNoPush ? 1 : 0);
}
void setSndLowAt(int lowAt) throws IOException {
setSndLowAt(intValue(), lowAt);
}
public void setTcpFastOpen(boolean enableTcpFastOpen) throws IOException {
setTcpFastOpen(intValue(), enableTcpFastOpen ? 1 : 0);
}
boolean isTcpNoPush() throws IOException {
return getTcpNoPush(intValue()) != 0;
}
int getSndLowAt() throws IOException {
return getSndLowAt(intValue());
}
AcceptFilter getAcceptFilter() throws IOException {
String[] result = getAcceptFilter(intValue());
return result == null ? PLATFORM_UNSUPPORTED : new AcceptFilter(result[0], result[1]);
}
public boolean isTcpFastOpen() throws IOException {
return isTcpFastOpen(intValue()) != 0;
}
PeerCredentials getPeerCredentials() throws IOException {
return getPeerCredentials(intValue());
}
long sendFile(DefaultFileRegion src, long baseOffset, long offset, long length) throws IOException {
// Open the file-region as it may be created via the lazy constructor. This is needed as we directly access
// the FileChannel field via JNI.
src.open();
long res = sendFile(intValue(), src, baseOffset, offset, length);
if (res >= 0) {
return res;
}
return ioResult("sendfile", (int) res);
}
/**
* Establish a connection to the given destination address, and send the given data to it.
*
* <strong>Note:</strong> This method relies on the {@code connectx(2)} system call, which is MacOS specific.
*
* @param source the source address we are connecting from.
* @param destination the destination address we are connecting to.
* @param data the data to copy to the kernel-side socket buffer.
* @param tcpFastOpen if {@code true}, set the flags needed to enable TCP FastOpen connecting.
* @return The number of bytes copied to the kernel-side socket buffer, or the number of bytes sent to the
* destination. This number is <em>negative</em> if connecting is left in an in-progress state,
* or <em>positive</em> if the connection was immediately established.
* @throws IOException if an IO error occurs, if the {@code data} is too big to send in one go,
* or if the system call is not supported on your platform.
Source
Frequently Asked Questions
What is the BsdSocket class?
BsdSocket is a class in the netty codebase, defined in transport-classes-kqueue/src/main/java/io/netty/channel/kqueue/BsdSocket.java.
Where is BsdSocket defined?
BsdSocket is defined in transport-classes-kqueue/src/main/java/io/netty/channel/kqueue/BsdSocket.java at line 40.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free