Lines Matching refs:fd

51     int fd;
81 printf("%d ", ufds[i].fd);
126 static int _close(int fd, int type) {
129 printf("%ld: close(%d)\n", pthread_self(), fd);
130 ret = close(fd);
131 printf("%ld: close(%d) = %d\n", pthread_self(), fd, ret);
137 static int _bind(int fd, int type) {
166 printf("%ld: bind(%d)\n", pthread_self(), fd);
167 ret = bind(fd, addr, len);
168 printf("%ld: bind(%d) = %d\n", pthread_self(), fd, ret);
174 static int _listen(int fd, int type) {
177 printf("%ld: listen(%d)\n", pthread_self(), fd);
178 ret = listen(fd, 1);
179 printf("%ld: listen(%d) = %d\n", pthread_self(), fd, ret);
185 static int _read(int fd) {
189 printf("%ld: read(%d)\n", pthread_self(), fd);
190 ret = read(fd, &buf, 1);
191 printf("%ld: read(%d) = %d [%d]\n", pthread_self(), fd, ret, (int)buf);
198 static int _accept(int fd, int type) {
226 printf("%ld: accept(%d)\n", pthread_self(), fd);
227 ret = accept(fd, addr, &len);
228 printf("%ld: accept(%d) = %d\n", pthread_self(), fd, ret);
251 static int _connect(int fd, int type) {
280 printf("%ld: connect(%d)\n", pthread_self(), fd);
281 ret = connect(fd, addr, len);
282 printf("%ld: connect(%d) = %d\n", pthread_self(), fd, ret);
288 static int _write(int fd, int type) {
292 printf("%ld: write(%d)\n", pthread_self(), fd);
293 ret = write(fd, &buf, 1);
294 printf("%ld: write(%d) = %d\n", pthread_self(), fd, ret);
300 static int _shutdown(int fd, int how) {
303 printf("%ld: shutdown(%d)\n", pthread_self(), fd);
304 ret = shutdown(fd, how);
305 printf("%ld: shutdown(%d) = %d\n", pthread_self(), fd, ret);
324 printf("\tfd %d ", ufds[i].fd); print_events(ufds[i].revents);
334 _close(args->fd, args->type);
339 int fd = (int)args;
342 pfd.fd = fd;
349 int fd = (int)args;
351 _read(fd);
356 int fd = (int)args;
359 pfd.fd = fd;
365 static void thread_shutdown(int fd) {
368 _shutdown(fd, SHUT_RDWR);
375 _accept(args->fd, args->type);
382 _connect(args->fd, args->type);
389 _close(args->fd, args->type);
391 _write(args->fd, args->type);
398 _accept(args->fd, args->type);
400 _write(args->fd, args->type);
407 args->fd = _socket(args->type);
408 _connect(args->fd, args->type);
413 int fd;
415 fd = _socket(type);
416 if (fd < 0) goto error;
418 if (_bind(fd, type) < 0) goto error;
420 if (_listen(fd, type) < 0) goto error;
423 _accept(fd, type);
433 int fd;
437 fd = _socket(type);
438 if (fd < 0) goto error;
440 if (_bind(fd, type) < 0) goto error;
442 if (_listen(fd, type) < 0) goto error;
444 args.fd = fd;
447 _accept(fd, type);
458 int fd;
462 fd = _socket(type);
463 if (fd < 0) goto error;
465 if (_bind(fd, type) < 0) goto error;
467 if (_listen(fd, type) < 0) goto error;
469 args.fd = fd;
473 _shutdown(fd, SHUT_RDWR);
477 _close(fd, type);
486 int fd;
490 fd = _socket(type);
491 if (fd < 0) goto error;
493 args.fd = fd;
497 _shutdown(fd, SHUT_RDWR);
501 _close(fd, type);
510 int fd;
516 fd = _socket(type);
517 if (fd < 0) goto error;
519 flags = fcntl(fd, F_GETFL);
522 if (fcntl(fd, F_SETFL, flags | O_NONBLOCK))
525 _connect(fd, type);
528 _shutdown(fd, SHUT_RDWR);
532 _close(fd, type);
541 int fd;
546 fd = _socket(type);
547 if (fd < 0) goto error;
549 flags = fcntl(fd, F_GETFL);
552 if (fcntl(fd, F_SETFL, flags | O_NONBLOCK))
555 _connect(fd, type);
559 _close(fd, type);
569 int fd;
573 fd = _socket(type);
574 if (fd < 0) goto error;
576 if (_bind(fd, type) < 0) goto error;
578 if (_listen(fd, type) < 0) goto error;
580 args.fd = fd;
583 _accept(fd, type);
595 int fd;
599 fd = _socket(type);
602 pthread_create(&t[i], NULL, (void *)thread_poll, (void *)fd);
606 _shutdown(fd, SHUT_RDWR);
611 _close(fd, type);
618 int fd;
622 fd = _socket(type);
625 pthread_create(&t[i], NULL, (void *)thread_poll, (void *)fd);
629 _close(fd, type);
639 int fd;
643 fd = _socket(type);
646 pthread_create(&t[i], NULL, (void *)thread_read, (void *)fd);
650 _close(fd, type);
660 int fd;
664 fd = _socket(type);
667 pthread_create(&t[i], NULL, (void *)thread_read, (void *)fd);
671 _shutdown(fd, SHUT_RDWR);
676 _close(fd, type);
695 a1.fd = fd1;
716 int fd;
722 fd = _socket(type);
723 if (fd < 0) goto error;
725 if (_bind(fd, type) < 0) goto error;
727 if (_listen(fd, type) < 0) goto error;
732 _accept(fd, type);