Lines Matching refs:sockfd
163 int sockfd = -1;
179 sockfd = socket(t->ai_family, t->ai_socktype, t->ai_protocol);
180 if (sockfd >= 0) {
181 if (!connect(sockfd, t->ai_addr, t->ai_addrlen))
183 close(sockfd);
184 sockfd = -1;
191 if (sockfd < 0) {
199 if (write(sockfd, msg, sizeof msg) != sizeof msg) {
204 if (read(sockfd, msg, sizeof msg) != sizeof msg ||
205 write(sockfd, "done", sizeof "done") != sizeof "done") {
220 close(sockfd);
239 int sockfd = -1, connfd;
255 sockfd = socket(t->ai_family, t->ai_socktype, t->ai_protocol);
256 if (sockfd >= 0) {
259 setsockopt(sockfd, SOL_SOCKET, SO_REUSEADDR, &n, sizeof n);
261 if (!bind(sockfd, t->ai_addr, t->ai_addrlen))
263 close(sockfd);
264 sockfd = -1;
271 if (sockfd < 0) {
276 if (listen(sockfd, 1) < 0) {
278 close(sockfd);
281 connfd = accept(sockfd, NULL, NULL);
282 close(sockfd);