Lines Matching refs:sockfd
149 int sockfd = -1;
165 sockfd = socket(t->ai_family, t->ai_socktype, t->ai_protocol);
166 if (sockfd >= 0) {
167 if (!connect(sockfd, t->ai_addr, t->ai_addrlen))
169 close(sockfd);
170 sockfd = -1;
177 if (sockfd < 0) {
184 if (write(sockfd, msg, sizeof msg) != sizeof msg) {
189 if (read(sockfd, msg, sizeof msg) != sizeof msg) {
195 write(sockfd, "done", sizeof "done");
205 close(sockfd);
224 int sockfd = -1, connfd;
240 sockfd = socket(t->ai_family, t->ai_socktype, t->ai_protocol);
241 if (sockfd >= 0) {
244 setsockopt(sockfd, SOL_SOCKET, SO_REUSEADDR, &n, sizeof n);
246 if (!bind(sockfd, t->ai_addr, t->ai_addrlen))
248 close(sockfd);
249 sockfd = -1;
256 if (sockfd < 0) {
261 listen(sockfd, 1);
262 connfd = accept(sockfd, NULL, 0);
263 close(sockfd);