Lines Matching defs:fd

57 int settimeo(int fd, int timeout_ms)
66 if (setsockopt(fd, SOL_SOCKET, SO_RCVTIMEO, &timeout,
72 if (setsockopt(fd, SOL_SOCKET, SO_SNDTIMEO, &timeout,
81 #define save_errno_close(fd) ({ int __save = errno; close(fd); errno = __save; })
86 int fd;
88 fd = socket(addr->sa_family, type, opts->proto);
89 if (fd < 0) {
94 if (settimeo(fd, opts->timeout_ms))
97 if (opts->post_socket_cb && opts->post_socket_cb(fd, NULL)) {
102 if (bind(fd, addr, addrlen) < 0) {
108 if (listen(fd, 1) < 0) {
114 return fd;
117 save_errno_close(fd);
136 static int reuseport_cb(int fd, const struct post_socket_opts *opts)
140 return setsockopt(fd, SOL_SOCKET, SO_REUSEPORT, &on, sizeof(on));
210 int fd, ret;
218 fd = socket(addr_in->sin_family, SOCK_STREAM, 0);
219 if (fd < 0) {
224 if (settimeo(fd, timeout_ms))
227 ret = sendto(fd, data, data_len, MSG_FASTOPEN, (struct sockaddr *)&addr,
234 return fd;
237 save_errno_close(fd);
241 static int connect_fd_to_addr(int fd,
248 ret = connect(fd, (const struct sockaddr *)addr, addrlen);
271 int fd;
276 fd = socket(addr->ss_family, type, opts->proto);
277 if (fd < 0) {
282 if (settimeo(fd, opts->timeout_ms))
285 if (connect_fd_to_addr(fd, addr, addrlen, opts->must_fail))
288 return fd;
291 save_errno_close(fd);
300 int fd, type, protocol;
332 fd = socket(addr_in->sin_family, type, protocol);
333 if (fd < 0) {
338 if (settimeo(fd, opts->timeout_ms))
342 setsockopt(fd, SOL_TCP, TCP_CONGESTION, opts->cc,
347 if (connect_fd_to_addr(fd, &addr, addrlen, opts->must_fail))
350 return fd;
353 save_errno_close(fd);
573 int fd;
583 int err = 0, fd;
585 fd = accept(a->fd, NULL, NULL);
586 while (fd == -1) {
593 if (settimeo(fd, 0)) {
599 nr_sent = send(fd, &batch,
617 if (fd >= 0)
618 close(fd);
626 int send_recv_data(int lfd, int fd, uint32_t total_bytes)
630 .fd = lfd,
647 nr_recv = recv(fd, &batch,