Lines Matching full:fd

51 	int fd;
53 fd = socket(AF_VSOCK, SOCK_STREAM, 0);
57 ret = connect(fd, &addr.sa, sizeof(addr.svm));
71 close(fd);
87 int fd;
92 fd = socket(AF_VSOCK, SOCK_STREAM, 0);
96 ret = connect(fd, &addr.sa, sizeof(addr.svm));
113 close(fd);
118 int fd;
120 fd = vsock_bind(VMADDR_CID_ANY, opts->peer_port, SOCK_STREAM);
128 close(fd);
133 int fd;
135 fd = vsock_stream_connect(opts->peer_cid, opts->peer_port);
136 if (fd < 0) {
141 send_byte(fd, 1, 0);
142 close(fd);
147 int fd;
149 fd = vsock_stream_accept(VMADDR_CID_ANY, opts->peer_port, NULL);
150 if (fd < 0) {
158 vsock_wait_remote_close(fd);
160 send_byte(fd, -EPIPE, 0);
161 recv_byte(fd, 1, 0);
162 recv_byte(fd, 0, 0);
163 close(fd);
168 int fd;
170 fd = vsock_stream_connect(opts->peer_cid, opts->peer_port);
171 if (fd < 0) {
179 vsock_wait_remote_close(fd);
181 send_byte(fd, -EPIPE, 0);
182 recv_byte(fd, 1, 0);
183 recv_byte(fd, 0, 0);
184 close(fd);
189 int fd;
191 fd = vsock_stream_accept(VMADDR_CID_ANY, opts->peer_port, NULL);
192 if (fd < 0) {
197 send_byte(fd, 1, 0);
198 close(fd);
260 int fd;
264 fd = vsock_seqpacket_connect(opts->peer_cid, opts->peer_port);
266 fd = vsock_stream_connect(opts->peer_cid, opts->peer_port);
268 if (fd < 0) {
278 send_buf(fd, buf, sizeof(buf), 0, sizeof(buf));
280 close(fd);
289 int fd;
292 fd = vsock_seqpacket_accept(VMADDR_CID_ANY, opts->peer_port, NULL);
294 fd = vsock_stream_accept(VMADDR_CID_ANY, opts->peer_port, NULL);
296 if (fd < 0) {
302 recv_buf(fd, buf_peek, sizeof(buf_peek), MSG_PEEK | MSG_DONTWAIT,
308 recv_buf(fd, buf_half, sizeof(buf_half), MSG_PEEK, sizeof(buf_half));
311 recv_buf(fd, buf_peek, sizeof(buf_peek), MSG_PEEK, sizeof(buf_peek));
324 recv_buf(fd, buf_half, sizeof(buf_half), MSG_PEEK | MSG_TRUNC,
328 recv_buf(fd, buf_normal, sizeof(buf_normal), 0, sizeof(buf_normal));
336 close(fd);
358 int fd;
360 fd = vsock_seqpacket_connect(opts->peer_cid, opts->peer_port);
361 if (fd < 0) {
402 send_buf(fd, buf, buf_size, flags, buf_size);
419 close(fd);
427 int fd;
431 fd = vsock_seqpacket_accept(VMADDR_CID_ANY, opts->peer_port, NULL);
432 if (fd < 0) {
439 setsockopt_ull_check(fd, AF_VSOCK, SO_VM_SOCKETS_BUFFER_MAX_SIZE,
443 setsockopt_ull_check(fd, AF_VSOCK, SO_VM_SOCKETS_BUFFER_SIZE,
466 recv_size = recvmsg(fd, &msg, 0);
483 close(fd);
495 int fd;
498 fd = vsock_seqpacket_connect(opts->peer_cid, opts->peer_port);
499 if (fd < 0) {
504 send_buf(fd, buf, sizeof(buf), 0, sizeof(buf));
507 close(fd);
512 int fd;
517 fd = vsock_seqpacket_accept(VMADDR_CID_ANY, opts->peer_port, NULL);
518 if (fd < 0) {
529 ssize_t ret = recvmsg(fd, &msg, MSG_TRUNC);
542 close(fd);
562 int fd;
568 fd = vsock_seqpacket_connect(opts->peer_cid, opts->peer_port);
569 if (fd < 0) {
577 setsockopt_timeval_check(fd, SOL_SOCKET, SO_RCVTIMEO, tv,
582 if (read(fd, &dummy, sizeof(dummy)) != -1) {
604 close(fd);
609 int fd;
611 fd = vsock_seqpacket_accept(VMADDR_CID_ANY, opts->peer_port, NULL);
612 if (fd < 0) {
618 close(fd);
627 int fd;
631 fd = vsock_seqpacket_connect(opts->peer_cid, opts->peer_port);
632 if (fd < 0) {
637 if (getsockopt(fd, AF_VSOCK, SO_VM_SOCKETS_BUFFER_SIZE,
658 send_buf(fd, data, buf_size, 0, -EMSGSIZE);
663 close(fd);
668 int fd;
670 fd = vsock_seqpacket_accept(VMADDR_CID_ANY, opts->peer_port, NULL);
671 if (fd < 0) {
678 close(fd);
686 int fd;
691 fd = vsock_seqpacket_connect(opts->peer_cid, opts->peer_port);
692 if (fd < 0) {
712 send_buf(fd, buf1, buf_size, 0, buf_size);
714 send_buf(fd, buf2, buf_size, 0, buf_size);
716 close(fd);
721 int fd;
731 fd = vsock_seqpacket_accept(VMADDR_CID_ANY, opts->peer_port, NULL);
732 if (fd < 0) {
757 res = read(fd, broken_buf, buf_size);
771 res = read(fd, valid_buf, buf_size);
797 close(fd);
804 int fd;
807 fd = vsock_stream_accept(VMADDR_CID_ANY, opts->peer_port, NULL);
808 if (fd < 0) {
814 send_byte(fd, 1, 0);
822 send_byte(fd, 1, 0);
827 close(fd);
836 int fd;
838 fd = vsock_stream_connect(opts->peer_cid, opts->peer_port);
839 if (fd < 0) {
844 setsockopt_int_check(fd, SOL_SOCKET, SO_RCVLOWAT,
850 fds.fd = fd;
886 recv_buf(fd, buf, sizeof(buf), MSG_DONTWAIT, RCVLOWAT_BUF_SIZE);
890 close(fd);
899 int fd;
902 fd = vsock_stream_connect(opts->peer_cid, opts->peer_port);
904 fd = vsock_seqpacket_connect(opts->peer_cid, opts->peer_port);
906 if (fd < 0) {
914 recv_buf(fd, NULL, sizeof(data), 0, -EFAULT);
924 recv_buf(fd, data, sizeof(data), MSG_DONTWAIT, expected_ret);
928 close(fd);
934 int fd;
937 fd = vsock_stream_accept(VMADDR_CID_ANY, opts->peer_port, NULL);
939 fd = vsock_seqpacket_accept(VMADDR_CID_ANY, opts->peer_port, NULL);
941 if (fd < 0) {
946 send_buf(fd, data, sizeof(data), 0, sizeof(data));
952 close(fd);
980 int fd;
982 fd = vsock_stream_connect(opts->peer_cid, opts->peer_port);
983 if (fd < 0) {
989 send_buf(fd, HELLO_STR, strlen(HELLO_STR), 0, strlen(HELLO_STR));
996 send_buf(fd, WORLD_STR, strlen(WORLD_STR), 0, strlen(WORLD_STR));
1002 close(fd);
1009 int fd;
1011 fd = vsock_stream_accept(VMADDR_CID_ANY, opts->peer_port, NULL);
1012 if (fd < 0) {
1021 recv_buf(fd, buf + read, to_read, 0, to_read);
1029 recv_buf(fd, buf + read, to_read, 0, to_read);
1034 recv_buf(fd, buf + read, to_read, MSG_DONTWAIT, -EAGAIN);
1043 close(fd);
1065 static void test_stream_check_sigpipe(int fd)
1079 res = send(fd, "A", 1, 0);
1105 res = send(fd, "A", 1, MSG_NOSIGNAL);
1126 int fd;
1134 fd = vsock_stream_connect(opts->peer_cid, opts->peer_port);
1135 if (fd < 0) {
1140 if (shutdown(fd, SHUT_WR)) {
1145 test_stream_check_sigpipe(fd);
1149 close(fd);
1154 int fd;
1156 fd = vsock_stream_accept(VMADDR_CID_ANY, opts->peer_port, NULL);
1157 if (fd < 0) {
1164 close(fd);
1169 int fd;
1177 fd = vsock_stream_connect(opts->peer_cid, opts->peer_port);
1178 if (fd < 0) {
1185 test_stream_check_sigpipe(fd);
1189 close(fd);
1194 int fd;
1196 fd = vsock_stream_accept(VMADDR_CID_ANY, opts->peer_port, NULL);
1197 if (fd < 0) {
1202 if (shutdown(fd, SHUT_RD)) {
1210 close(fd);
1285 int fd;
1287 fd = vsock_connect(opts->peer_cid, opts->peer_port, type);
1288 if (fd < 0) {
1296 send_buf(fd, buf, sizeof(buf), 0, sizeof(buf));
1305 if (!vsock_wait_sent(fd))
1308 close(fd);
1334 int fd;
1336 fd = vsock_connect(opts->peer_cid, opts->peer_port, type);
1337 if (fd < 0) {
1346 if (!vsock_ioctl_int(fd, SIOCINQ, MSG_BUF_IOCTL_LEN)) {
1351 recv_buf(fd, buf, sizeof(buf), 0, sizeof(buf));
1353 vsock_ioctl_int(fd, SIOCINQ, 0);
1356 close(fd);
1411 int fd;
1413 fd = vsock_stream_connect(opts->peer_cid, opts->peer_port);
1414 if (fd < 0) {
1429 recv_byte(fd, 1, 0);
1431 if (send(fd, buf, buf_size, 0) != buf_size) {
1437 close(fd);
1448 int fd;
1450 fd = vsock_stream_accept(VMADDR_CID_ANY, opts->peer_port, NULL);
1451 if (fd < 0) {
1461 setsockopt_ull_check(fd, AF_VSOCK, SO_VM_SOCKETS_BUFFER_SIZE,
1472 setsockopt_int_check(fd, SOL_SOCKET, SO_RCVLOWAT,
1482 send_byte(fd, 1, 0);
1494 res = recv(fd, buf, buf_size, MSG_PEEK);
1509 recv_buf(fd, buf, recv_buf_size, 0, recv_buf_size);
1515 setsockopt_int_check(fd, SOL_SOCKET, SO_RCVLOWAT,
1519 fds.fd = fd;
1537 recv_buf(fd, buf, recv_buf_size, MSG_DONTWAIT, recv_buf_size);
1547 close(fd);
1577 int fd;
1583 fd = vsock_stream_connect(opts->peer_cid, opts->peer_port);
1584 if (fd >= 0)
1585 close(fd);
1594 int fd;
1597 fd = vsock_stream_listen(VMADDR_CID_ANY, opts->peer_port);
1599 close(fd);
1607 int fd;
1609 fd = vsock_stream_connect(opts->peer_cid, opts->peer_port);
1610 if (fd < 0) {
1615 enable_so_zerocopy_check(fd);
1616 send_byte(fd, 1, MSG_ZEROCOPY);
1618 fds.fd = fd;
1625 close(fd);
1630 int fd;
1632 fd = vsock_stream_accept(VMADDR_CID_ANY, opts->peer_port, NULL);
1633 if (fd < 0) {
1638 recv_byte(fd, 1, 0);
1639 vsock_wait_remote_close(fd);
1640 close(fd);
1698 * int fd;
1701 * fd = vsock_stream_accept(VMADDR_CID_ANY, opts->peer_port, NULL);
1702 * vsock_wait_remote_close(fd);
1703 * close(fd);
1719 int fd, res;
1735 fd = vsock_stream_connect(opts->peer_cid, opts->peer_port);
1736 if (fd < 0) {
1741 enable_so_zerocopy_check(fd);
1766 res = sendmsg(fd, &msg, MSG_ZEROCOPY);
1773 close(fd);
1778 int fd;
1780 fd = vsock_stream_accept(VMADDR_CID_ANY, opts->peer_port, NULL);
1781 if (fd < 0) {
1786 vsock_wait_remote_close(fd);
1787 close(fd);
1797 int fd, i, c;
1804 fd = vsock_bind_try(cid, VMADDR_PORT_ANY, SOCK_STREAM);
1805 if (fd < 0) {
1815 if (getsockname(fd, (struct sockaddr *)&addr, &alen)) {
1824 close(fd);
1831 fd = socket(AF_VSOCK, SOCK_STREAM | SOCK_NONBLOCK, 0);
1832 if (fd < 0) {
1845 if (!connect(fd, (struct sockaddr *)&addr, alen)) {
1866 (void)connect(fd, (struct sockaddr *)&addr, alen);
1872 close(fd);
1901 int fd;
1903 fd = socket(AF_VSOCK, SOCK_STREAM, 0);
1904 if (fd < 0) {
1909 if (!vsock_connect_fd(fd, opts->peer_cid, opts->peer_port)) {
1917 if (vsock_connect_fd(fd, opts->peer_cid, opts->peer_port)) {
1922 close(fd);
1927 int fd;
1931 fd = vsock_stream_accept(VMADDR_CID_ANY, opts->peer_port, NULL);
1932 if (fd < 0) {
1937 vsock_wait_remote_close(fd);
1938 close(fd);
2122 int fd;
2124 fd = vsock_stream_connect(opts->peer_cid, opts->peer_port);
2125 if (fd < 0) {
2130 enable_so_linger(fd, 1);
2131 close(fd);
2136 int fd;
2138 fd = vsock_stream_accept(VMADDR_CID_ANY, opts->peer_port, NULL);
2139 if (fd < 0) {
2144 vsock_wait_remote_close(fd);
2145 close(fd);
2155 int fd;
2157 fd = vsock_stream_connect(opts->peer_cid, opts->peer_port);
2158 if (fd < 0) {
2163 enable_so_linger(fd, LINGER_TIMEOUT);
2164 send_byte(fd, 1, 0); /* Left unread to expose incorrect behaviour. */
2165 waited = vsock_wait_sent(fd);
2168 close(fd);
2183 int fd;
2185 fd = vsock_stream_accept(VMADDR_CID_ANY, opts->peer_port, NULL);
2186 if (fd < 0) {
2192 close(fd);