Lines Matching refs:sockfd
136 int sockfd = -1;
152 sockfd = socket(t->ai_family, t->ai_socktype, t->ai_protocol);
153 if (sockfd >= 0) {
154 if (!connect(sockfd, t->ai_addr, t->ai_addrlen))
156 close(sockfd);
157 sockfd = -1;
164 if (sockfd < 0) {
172 if (write(sockfd, msg, sizeof msg) != sizeof msg) {
177 if (read(sockfd, msg, sizeof msg) != sizeof msg ||
178 write(sockfd, "done", sizeof "done") != sizeof "done") {
193 close(sockfd);
211 int sockfd = -1, connfd;
227 sockfd = socket(t->ai_family, t->ai_socktype, t->ai_protocol);
228 if (sockfd >= 0) {
231 setsockopt(sockfd, SOL_SOCKET, SO_REUSEADDR, &n, sizeof n);
233 if (!bind(sockfd, t->ai_addr, t->ai_addrlen))
235 close(sockfd);
236 sockfd = -1;
243 if (sockfd < 0) {
248 if (listen(sockfd, 1) < 0) {
250 close(sockfd);
253 connfd = accept(sockfd, NULL, NULL);
254 close(sockfd);