MCPcopy Create free account
hub / github.com/aria2/aria2 / create

Method create

src/SocketCore.cc:195–218  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

193} // namespace
194
195void SocketCore::create(int family, int protocol)
196{
197 int errNum;
198 closeConnection();
199 sock_t fd = socket(family, sockType_, protocol);
200 errNum = SOCKET_ERRNO;
201 if (fd == (sock_t)-1) {
202 throw DL_ABORT_EX(
203 fmt("Failed to create socket. Cause:%s", errorMsg(errNum).c_str()));
204 }
205 util::make_fd_cloexec(fd);
206 int sockopt = 1;
207 if (setsockopt(fd, SOL_SOCKET, SO_REUSEADDR, (a2_sockopt_t)&sockopt,
208 sizeof(sockopt)) < 0) {
209 errNum = SOCKET_ERRNO;
210 CLOSE(fd);
211 throw DL_ABORT_EX(
212 fmt("Failed to create socket. Cause:%s", errorMsg(errNum).c_str()));
213 }
214
215 applySocketBufferSize(fd);
216
217 sockfd_ = fd;
218}
219
220static sock_t bindInternal(int family, int socktype, int protocol,
221 const struct sockaddr* addr, socklen_t addrlen,

Callers

nothing calls this directly

Calls 4

fmtFunction · 0.85
errorMsgFunction · 0.85
make_fd_cloexecFunction · 0.85
applySocketBufferSizeFunction · 0.85

Tested by

no test coverage detected