Changeset 2 for pjproject/main/pjlib/src/pj/ioqueue_select.c
- Timestamp:
- Nov 1, 2005 4:42:51 PM (19 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
pjproject/main/pjlib/src/pj/ioqueue_select.c
r1 r2 499 499 # if defined(PJ_WIN32) && PJ_WIN32 != 0 500 500 rc = pj_sock_recv(h->fd, h->rd_buf, &bytes_read, 0); 501 # elif defined(PJ_LINUX) && PJ_LINUX != 0 501 # elif (defined(PJ_LINUX) && PJ_LINUX != 0) || \ 502 (defined(PJ_SUNOS) && PJ_SUNOS != 0) 502 503 bytes_read = read(h->fd, h->rd_buf, bytes_read); 503 504 rc = (bytes_read >= 0) ? PJ_SUCCESS : pj_get_os_error(); … … 506 507 rc = (bytes_read >= 0) ? PJ_SUCCESS : -bytes_read; 507 508 # else 508 # error " Check this man!"509 # error "Implement read() for this platform!" 509 510 # endif 510 511 } … … 560 561 PJ_IOQUEUE_IS_CONNECT_OP(h->op)); 561 562 562 #if PJ_HAS_TCP563 #if defined(PJ_HAS_TCP) && PJ_HAS_TCP!=0 563 564 if ((h->op & PJ_IOQUEUE_OP_CONNECT)) { 564 565 /* Completion of connect() operation */ 565 566 pj_ssize_t bytes_transfered; 566 567 567 #if defined(PJ_LINUX) || defined(PJ_LINUX_KERNEL) 568 #if (defined(PJ_LINUX) && PJ_LINUX!=0) || \ 569 (defined(PJ_LINUX_KERNEL) && PJ_LINUX_KERNEL!=0) 568 570 /* from connect(2): 569 571 * On Linux, use getsockopt to read the SO_ERROR option at … … 585 587 bytes_transfered = value; 586 588 } 587 #elif defined(PJ_WIN32) 589 #elif defined(PJ_WIN32) && PJ_WIN32!=0 588 590 bytes_transfered = 0; /* success */ 589 591 #else 590 # error "Got to check this one!" 592 /* Excellent information in D.J. Bernstein page: 593 * http://cr.yp.to/docs/connect.html 594 * 595 * Seems like the most portable way of detecting connect() 596 * failure is to call getpeername(). If socket is connected, 597 * getpeername() will return 0. If the socket is not connected, 598 * it will return ENOTCONN, and read(fd, &ch, 1) will produce 599 * the right errno through error slippage. This is a combination 600 * of suggestions from Douglas C. Schmidt and Ken Keys. 601 */ 602 int gp_rc; 603 struct sockaddr_in addr; 604 socklen_t addrlen = sizeof(addr); 605 606 gp_rc = getpeername(h->fd, (struct sockaddr*)&addr, &addrlen); 607 bytes_transfered = gp_rc; 591 608 #endif 592 609
Note: See TracChangeset
for help on using the changeset viewer.