Lines Matching refs:sockfd
137 int sockfd = -1;
153 sockfd = socket(t->ai_family, t->ai_socktype, t->ai_protocol);
154 if (sockfd >= 0) {
155 if (!connect(sockfd, t->ai_addr, t->ai_addrlen))
157 close(sockfd);
158 sockfd = -1;
165 if (sockfd < 0) {
172 if (write(sockfd, msg, sizeof msg) != sizeof msg) {
177 if (read(sockfd, msg, sizeof msg) != sizeof msg) {
183 write(sockfd, "done", sizeof "done");
193 close(sockfd);
212 int sockfd = -1, connfd;
228 sockfd = socket(t->ai_family, t->ai_socktype, t->ai_protocol);
229 if (sockfd >= 0) {
232 setsockopt(sockfd, SOL_SOCKET, SO_REUSEADDR, &n, sizeof n);
234 if (!bind(sockfd, t->ai_addr, t->ai_addrlen))
236 close(sockfd);
237 sockfd = -1;
244 if (sockfd < 0) {
249 listen(sockfd, 1);
250 connfd = accept(sockfd, NULL, 0);
251 close(sockfd);