1607 |nReceived| |
1609 |nReceived| |
1608 |
1610 |
1609 %{ |
1611 %{ |
1610 #ifndef NO_SOCKET |
1612 #ifndef NO_SOCKET |
1611 OBJ fp = __INST(filePointer); |
1613 OBJ fp = __INST(filePointer); |
1612 int objSize, offs; |
|
1613 int sock; |
|
1614 int n; |
|
1615 char *extPtr; |
|
1616 unsigned char *buffer; |
|
1617 unsigned char *allocatedBuffer; |
|
1618 int flags = 0; |
|
1619 |
1614 |
1620 if (fp != nil) { |
1615 if (fp != nil) { |
|
1616 SOCKET sock; |
|
1617 int objSize, offs; |
|
1618 int n; |
|
1619 char *extPtr; |
|
1620 unsigned char *buffer; |
|
1621 unsigned char *allocatedBuffer; |
|
1622 int flags = 0; |
|
1623 |
1621 sock = SOCKET_FROM_FILE_OBJECT(fp); |
1624 sock = SOCKET_FROM_FILE_OBJECT(fp); |
1622 |
1625 |
1623 if (! setupBufferParameters(aDataBuffer, startIndex, &extPtr, &offs, &objSize)) goto bad; |
1626 if (! setupBufferParameters(aDataBuffer, startIndex, &extPtr, &offs, &objSize)) goto bad; |
1624 if (__isSmallInteger(nBytes)) { |
1627 if (__isSmallInteger(nBytes)) { |
1625 if (__intVal(nBytes) < objSize) { |
1628 if (__intVal(nBytes) < objSize) { |
1634 allocatedBuffer = buffer = (char *)malloc(objSize); |
1637 allocatedBuffer = buffer = (char *)malloc(objSize); |
1635 } |
1638 } |
1636 |
1639 |
1637 do { |
1640 do { |
1638 __threadErrno = 0; |
1641 __threadErrno = 0; |
1639 n = STX_API_CALL4("recv", recv, sock, buffer, objSize, flags); |
1642 n = STX_WSA_CALL4("recv", recv, sock, buffer, objSize, flags); |
1640 } while ((n < 0) && (__threadErrno == EINTR)); |
1643 } while ((n < 0) && (__threadErrno == EINTR)); |
1641 |
1644 |
1642 if (allocatedBuffer) { |
1645 if (allocatedBuffer) { |
1643 if (n > 0) { |
1646 if (n > 0) { |
1644 bcopy(allocatedBuffer, (char *)__InstPtr(aDataBuffer) + offs, n); |
1647 bcopy(allocatedBuffer, (char *)__InstPtr(aDataBuffer) + offs, n); |
1720 ]. |
1723 ]. |
1721 |
1724 |
1722 %{ |
1725 %{ |
1723 #ifndef NO_SOCKET |
1726 #ifndef NO_SOCKET |
1724 OBJ fp = __INST(filePointer); |
1727 OBJ fp = __INST(filePointer); |
1725 int objSize; |
|
1726 int sock; |
|
1727 union sockaddr_u sa; |
|
1728 int alen = 0; |
|
1729 int n, offs; |
|
1730 int flags = 0; |
|
1731 char *extPtr; |
|
1732 unsigned char *allocatedBuffer = NULL; |
|
1733 unsigned char *buffer = NULL; |
|
1734 |
1728 |
1735 if (fp != nil) { |
1729 if (fp != nil) { |
|
1730 SOCKET sock; |
|
1731 int objSize; |
|
1732 union sockaddr_u sa; |
|
1733 int alen = 0; |
|
1734 int n, offs; |
|
1735 int flags = 0; |
|
1736 char *extPtr; |
|
1737 unsigned char *allocatedBuffer = NULL; |
|
1738 unsigned char *buffer = NULL; |
|
1739 |
1736 sock = SOCKET_FROM_FILE_OBJECT(fp); |
1740 sock = SOCKET_FROM_FILE_OBJECT(fp); |
1737 |
1741 |
1738 if (! setupBufferParameters(aDataBuffer, startIndex, &extPtr, &offs, &objSize)) goto bad; |
1742 if (! setupBufferParameters(aDataBuffer, startIndex, &extPtr, &offs, &objSize)) goto bad; |
1739 if (__isSmallInteger(nBytes)) { |
1743 if (__isSmallInteger(nBytes)) { |
1740 if (__intVal(nBytes) < objSize) { |
1744 if (__intVal(nBytes) < objSize) { |
1749 } |
1753 } |
1750 |
1754 |
1751 do { |
1755 do { |
1752 __threadErrno = 0; |
1756 __threadErrno = 0; |
1753 alen = sizeof(sa); |
1757 alen = sizeof(sa); |
1754 n = STX_API_CALL6("recvfrom", recvfrom, sock, buffer, objSize, flags, (struct sockaddr *)&sa, &alen); |
1758 n = STX_WSA_CALL6("recvfrom", recvfrom, sock, buffer, objSize, flags, (struct sockaddr *)&sa, &alen); |
1755 } while ((n < 0) && (__threadErrno == EINTR)); |
1759 } while ((n < 0) && (__threadErrno == EINTR)); |
1756 |
1760 |
1757 if (allocatedBuffer) { |
1761 if (allocatedBuffer) { |
1758 if (n > 0) { |
1762 if (n > 0) { |
1759 bcopy(allocatedBuffer, (char *)__InstPtr(aDataBuffer) + offs, n); |
1763 bcopy(allocatedBuffer, (char *)__InstPtr(aDataBuffer) + offs, n); |
1838 |
1842 |
1839 |nReceived portNo| |
1843 |nReceived portNo| |
1840 |
1844 |
1841 %{ |
1845 %{ |
1842 #ifndef NO_SOCKET |
1846 #ifndef NO_SOCKET |
1843 OBJ oClass; |
|
1844 OBJ fp = __INST(filePointer); |
1847 OBJ fp = __INST(filePointer); |
1845 int objSize; |
|
1846 int sock; |
|
1847 int n; |
|
1848 char *extPtr; |
|
1849 int _flags = 0; |
|
1850 int offs; |
|
1851 unsigned long norder; |
|
1852 unsigned char *buffer; |
|
1853 unsigned char *allocatedBuffer; |
|
1854 |
1848 |
1855 if ((fp != nil) |
1849 if ((fp != nil) |
1856 && __isSmallInteger(startIndex) |
1850 && __isSmallInteger(startIndex) |
1857 && __isSmallInteger(nBytes)) { |
1851 && __isSmallInteger(nBytes)) { |
|
1852 SOCKET sock; |
|
1853 int objSize; |
|
1854 int n; |
|
1855 char *extPtr; |
|
1856 int _flags = 0; |
|
1857 int offs; |
|
1858 unsigned long norder; |
|
1859 unsigned char *buffer; |
|
1860 unsigned char *allocatedBuffer; |
|
1861 |
1858 _flags = __longIntVal(flags); |
1862 _flags = __longIntVal(flags); |
1859 |
1863 |
1860 sock = SOCKET_FROM_FILE_OBJECT(fp); |
1864 sock = SOCKET_FROM_FILE_OBJECT(fp); |
1861 |
1865 |
1862 if (! setupBufferParameters(aDataBuffer, startIndex, &extPtr, &offs, &objSize)) goto bad; |
1866 if (! setupBufferParameters(aDataBuffer, startIndex, &extPtr, &offs, &objSize)) goto bad; |
1878 bcopy((char *)__InstPtr(aDataBuffer) + offs, allocatedBuffer, objSize); |
1882 bcopy((char *)__InstPtr(aDataBuffer) + offs, allocatedBuffer, objSize); |
1879 } |
1883 } |
1880 |
1884 |
1881 do { |
1885 do { |
1882 __threadErrno = 0; |
1886 __threadErrno = 0; |
1883 n = STX_API_CALL4("send", send, sock, buffer, objSize, _flags); |
1887 n = STX_WSA_CALL4("send", send, sock, buffer, objSize, _flags); |
1884 } while ((n < 0) && (__threadErrno == EINTR)); |
1888 } while ((n < 0) && (__threadErrno == EINTR)); |
1885 |
1889 |
1886 if (allocatedBuffer) { |
1890 if (allocatedBuffer) { |
1887 free(allocatedBuffer); |
1891 free(allocatedBuffer); |
1888 } |
1892 } |
1963 ]. |
1967 ]. |
1964 addr := domainClass hostAddress:anAddressBuffer. |
1968 addr := domainClass hostAddress:anAddressBuffer. |
1965 ]. |
1969 ]. |
1966 %{ |
1970 %{ |
1967 #ifndef NO_SOCKET |
1971 #ifndef NO_SOCKET |
1968 OBJ oClass; |
|
1969 OBJ fp = __INST(filePointer); |
1972 OBJ fp = __INST(filePointer); |
1970 int objSize; |
|
1971 struct sockaddr *sockaddr_ptr; |
|
1972 union sockaddr_u sa; |
|
1973 int alen = 0; |
|
1974 int sockAddrOffs, sockaddr_size; |
|
1975 int sock; |
|
1976 int n; |
|
1977 char *extPtr; |
|
1978 int _flags = 0; |
|
1979 int offs; |
|
1980 unsigned long norder; |
|
1981 unsigned char *buffer; |
|
1982 unsigned char *allocatedBuffer; |
|
1983 |
1973 |
1984 if ((fp != nil) |
1974 if ((fp != nil) |
1985 && __isSmallInteger(startIndex) |
1975 && __isSmallInteger(startIndex) |
1986 && __isSmallInteger(nBytes)) { |
1976 && __isSmallInteger(nBytes)) { |
|
1977 SOCKET sock; |
|
1978 int objSize; |
|
1979 struct sockaddr *sockaddr_ptr; |
|
1980 union sockaddr_u sa; |
|
1981 int alen = 0; |
|
1982 int sockAddrOffs, sockaddr_size; |
|
1983 int n; |
|
1984 char *extPtr; |
|
1985 int _flags = 0; |
|
1986 int offs; |
|
1987 unsigned long norder; |
|
1988 unsigned char *buffer; |
|
1989 unsigned char *allocatedBuffer; |
|
1990 |
1987 _flags = __longIntVal(flags); |
1991 _flags = __longIntVal(flags); |
1988 sock = SOCKET_FROM_FILE_OBJECT(fp); |
1992 sock = SOCKET_FROM_FILE_OBJECT(fp); |
1989 |
1993 |
1990 if (! __isBytes(addr)) { |
1994 if (! __isBytes(addr)) { |
1991 sockaddr_size = 0; |
1995 sockaddr_size = 0; |
2022 bcopy((char *)__InstPtr(aDataBuffer) + offs, allocatedBuffer, objSize); |
2026 bcopy((char *)__InstPtr(aDataBuffer) + offs, allocatedBuffer, objSize); |
2023 } |
2027 } |
2024 |
2028 |
2025 do { |
2029 do { |
2026 __threadErrno = 0; |
2030 __threadErrno = 0; |
2027 n = STX_API_CALL6("sendto", sendto, sock, buffer, objSize, _flags, sockaddr_ptr, sockaddr_size); |
2031 n = STX_WSA_CALL6("sendto", sendto, sock, buffer, objSize, _flags, sockaddr_ptr, sockaddr_size); |
2028 } while ((n < 0) && (__threadErrno == EINTR)); |
2032 } while ((n < 0) && (__threadErrno == EINTR)); |
2029 |
2033 |
2030 if (allocatedBuffer) { |
2034 if (allocatedBuffer) { |
2031 free(allocatedBuffer); |
2035 free(allocatedBuffer); |
2032 } |
2036 } |
2201 DBGPRINTF(("SOCKET: setsockopt - SO_REUSEADDR failed\n")); |
2206 DBGPRINTF(("SOCKET: setsockopt - SO_REUSEADDR failed\n")); |
2202 } |
2207 } |
2203 } |
2208 } |
2204 # endif /* SO_REUSEADDR */ |
2209 # endif /* SO_REUSEADDR */ |
2205 |
2210 |
2206 # ifdef DO_WRAP_CALLS |
2211 # ifdef BIND_BLOCKS |
|
2212 # ifdef DO_WRAP_CALLS |
2207 do { |
2213 do { |
2208 __threadErrno = 0; |
2214 __threadErrno = 0; |
2209 ret = STX_API_CALL3("bind", bind, sock, &sa, sockaddr_size); |
2215 ret = STX_WSA_CALL3("bind", bind, sock, &sa, sockaddr_size); |
2210 } while ((ret < 0) && (__threadErrno == EINTR)); |
2216 } while ((ret < 0) && (__threadErrno == EINTR)); |
2211 # else |
2217 # else |
2212 __BEGIN_INTERRUPTABLE__ |
2218 __BEGIN_INTERRUPTABLE__ |
2213 do { |
2219 do { |
2214 ret = bind(sock, (struct sockaddr *)&sa, sockaddr_size); |
2220 ret = bind(sock, (struct sockaddr *)&sa, sockaddr_size); |
2215 } while ((ret < 0) && (errno == EINTR)); |
2221 } while ((ret < 0) && (errno == EINTR)); |
2216 __END_INTERRUPTABLE__ |
2222 __END_INTERRUPTABLE__ |
|
2223 # endif |
|
2224 # else |
|
2225 ret = bind(sock, (struct sockaddr *)&sa, sockaddr_size); |
2217 # endif |
2226 # endif |
2218 if (ret < 0) { |
2227 if (ret < 0) { |
2219 DBGPRINTF(("SOCKET: bind failed errno=%d\n", errno)); |
2228 DBGPRINTF(("SOCKET: bind failed errno=%d\n", errno)); |
2220 __INST(lastErrorNumber) = __MKSMALLINT(errno); |
2229 __INST(lastErrorNumber) = __MKSMALLINT(errno); |
2221 RETURN (false); |
2230 RETURN (false); |
2563 |
2576 |
2564 #ifdef LISTEN_BLOCKS |
2577 #ifdef LISTEN_BLOCKS |
2565 # ifdef DO_WRAP_CALLS |
2578 # ifdef DO_WRAP_CALLS |
2566 do { |
2579 do { |
2567 __threadErrno = 0; |
2580 __threadErrno = 0; |
2568 ret = STX_API_CALL2("listen", listen, sock, __intVal(aNumber)); |
2581 ret = STX_WSA_CALL2("listen", listen, sock, __intVal(aNumber)); |
2569 } while ((ret < 0) && (__threadErrno == EINTR)); |
2582 } while ((ret < 0) && (__threadErrno == EINTR)); |
2570 # else |
2583 # else |
2571 __BEGIN_INTERRUPTABLE__ |
2584 __BEGIN_INTERRUPTABLE__ |
2572 do { |
2585 do { |
2573 ret = listen(sock, __intVal(aNumber)); |
2586 ret = listen(sock, __intVal(aNumber)); |
2613 |
2626 |
2614 OBJ fp; |
2627 OBJ fp; |
2615 |
2628 |
2616 fp = __INST(filePointer); |
2629 fp = __INST(filePointer); |
2617 if ((fp != nil) && __isSmallInteger(howNum)) { |
2630 if ((fp != nil) && __isSmallInteger(howNum)) { |
2618 int sock; |
2631 SOCKET sock; |
2619 int ret; |
2632 int ret; |
2620 |
2633 |
2621 __INST(filePointer) = nil; |
2634 __INST(filePointer) = nil; |
2622 sock = SOCKET_FROM_FILE_OBJECT(fp); |
2635 sock = SOCKET_FROM_FILE_OBJECT(fp); |
2623 # ifdef DO_WRAP_CALLS |
2636 # ifdef DO_WRAP_CALLS |
2624 do { |
2637 do { |
2625 __threadErrno = 0; |
2638 __threadErrno = 0; |
2626 ret = STX_API_CALL2("shutdown", shutdown, sock, __intVal(howNum)); |
2639 ret = STX_WSA_CALL2("shutdown", shutdown, sock, __intVal(howNum)); |
2627 } while ((ret < 0) && (__threadErrno == EINTR)); |
2640 } while ((ret < 0) && (__threadErrno == EINTR)); |
2628 # else |
2641 # else |
2629 __BEGIN_INTERRUPTABLE__ |
2642 __BEGIN_INTERRUPTABLE__ |
2630 shutdown(sock, __intVal(howNum)); |
2643 shutdown(sock, __intVal(howNum)); |
2631 __END_INTERRUPTABLE__ |
2644 __END_INTERRUPTABLE__ |
3132 * connect |
3146 * connect |
3133 */ |
3147 */ |
3134 # ifdef DO_WRAP_CALLS |
3148 # ifdef DO_WRAP_CALLS |
3135 do { |
3149 do { |
3136 __threadErrno = 0; |
3150 __threadErrno = 0; |
3137 ret = STX_API_CALL3("connect", connect, sock, &sa, sockaddr_size); |
3151 ret = STX_WSA_CALL3("connect", connect, sock, &sa, sockaddr_size); |
3138 DBGPRINTF(("SOCKET: connect returns %d\n", ret)); |
3152 DBGPRINTF(("SOCKET: connect returns %d\n", ret)); |
3139 } while ((ret < 0) && (__threadErrno == EINTR)); |
3153 } while ((ret < 0) && (__threadErrno == EINTR)); |
3140 # else |
3154 # else |
3141 __BEGIN_INTERRUPTABLE__ |
3155 __BEGIN_INTERRUPTABLE__ |
3142 do { |
3156 do { |
3266 addr := domainClass new. |
3280 addr := domainClass new. |
3267 |
3281 |
3268 %{ |
3282 %{ |
3269 #ifndef NO_SOCKET |
3283 #ifndef NO_SOCKET |
3270 OBJ fp = __INST(filePointer); |
3284 OBJ fp = __INST(filePointer); |
3271 OBJ addrClass; |
3285 SOCKET sock; |
3272 int sock; |
|
3273 int ret; |
3286 int ret; |
3274 union sockaddr_u sa; |
3287 union sockaddr_u sa; |
3275 int alen, alen0; |
3288 int alen, alen0; |
3276 char *addrP; |
3289 char *addrP; |
3277 int addrObjSize, nAddrInstVars, nAddrInstBytes; |
3290 int addrObjSize, nAddrInstBytes; |
3278 |
3291 |
3279 if (!__isSmallInteger(addrLen)) { |
3292 if (!__isSmallInteger(addrLen)) { |
3280 DBGPRINTF(("SOCKET: bad addrLen\n")); |
3293 DBGPRINTF(("SOCKET: bad addrLen\n")); |
3281 error = @symbol(badArgument); |
3294 error = @symbol(badArgument); |
3282 goto err; |
3295 goto err; |
3532 * get address and protocol-family |
3547 * get address and protocol-family |
3533 */ |
3548 */ |
3534 dom = __intVal(domainCode); |
3549 dom = __intVal(domainCode); |
3535 typ = __intVal(typeCode); |
3550 typ = __intVal(typeCode); |
3536 |
3551 |
3537 # ifdef DO_WRAP_CALLS |
3552 # ifdef SOCKET_BLOCKS |
|
3553 # ifdef DO_WRAP_CALLS |
3538 do { |
3554 do { |
3539 __threadErrno = 0; |
3555 __threadErrno = 0; |
3540 sock = STX_API_CALL3("socket", socket, dom, typ, proto); |
3556 sock = STX_WSA_CALL3("socket", socket, dom, typ, proto); |
3541 } while ((sock < 0) && (__threadErrno == EINTR)); |
3557 } while ((sock < 0) && (__threadErrno == EINTR)); |
3542 # else |
3558 # else |
3543 __BEGIN_INTERRUPTABLE__ |
3559 __BEGIN_INTERRUPTABLE__ |
3544 do { |
3560 do { |
3545 DBGPRINTF(("SOCKET: opening socket domain=%d type=%d proto=%d\n", dom, typ, proto)); |
3561 DBGPRINTF(("SOCKET: opening socket domain=%d type=%d proto=%d\n", dom, typ, proto)); |
3546 sock = socket(dom, typ, proto); |
3562 sock = socket(dom, typ, proto); |
3547 # if defined(EPROTONOSUPPORT) /* for SGI */ |
3563 # if defined(EPROTONOSUPPORT) /* for SGI */ |
3548 if ((proto != 0) && (sock < 0) && (errno == EPROTONOSUPPORT)) { |
3564 if ((proto != 0) && (sock < 0) && (errno == EPROTONOSUPPORT)) { |
3549 DBGPRINTF(("SOCKET: retry with UNSPEC protocol\n")); |
3565 DBGPRINTF(("SOCKET: retry with UNSPEC protocol\n")); |
3550 proto = 0; |
3566 proto = 0; |
3551 sock = socket(dom, typ, 0); |
3567 sock = socket(dom, typ, 0); |
3552 } |
3568 } |
3553 # endif |
3569 # endif |
3554 } while ((sock < 0) && (errno == EINTR)); |
3570 } while ((sock < 0) && (errno == EINTR)); |
3555 __END_INTERRUPTABLE__ |
3571 __END_INTERRUPTABLE__ |
|
3572 # endif |
|
3573 # else |
|
3574 sock = socket(dom, typ, proto); |
|
3575 # if defined(EPROTONOSUPPORT) /* for SGI */ |
|
3576 if ((proto != 0) && (sock < 0) && (errno == EPROTONOSUPPORT)) { |
|
3577 DBGPRINTF(("SOCKET: retry with UNSPEC protocol\n")); |
|
3578 proto = 0; |
|
3579 sock = socket(dom, typ, 0); |
|
3580 } |
|
3581 # endif |
3556 # endif |
3582 # endif |
3557 |
3583 |
3558 DBGFPRINTF((stderr, "socket create newSock=%d\n", sock)); |
3584 DBGFPRINTF((stderr, "socket create newSock=%d\n", sock)); |
3559 |
3585 |
3560 if (sock < 0) { |
3586 # ifdef WIN32 |
|
3587 if (sock == INVALID_SOCKET) |
|
3588 # else |
|
3589 if (sock < 0) |
|
3590 # endif |
|
3591 { |
3561 DBGPRINTF(("SOCKET: socket(dom=%d typ=%d proto=%d) call failed errno=%d\n", dom, typ, proto, errno)); |
3592 DBGPRINTF(("SOCKET: socket(dom=%d typ=%d proto=%d) call failed errno=%d\n", dom, typ, proto, errno)); |
3562 __INST(lastErrorNumber) = __MKSMALLINT(errno); |
3593 __INST(lastErrorNumber) = __MKSMALLINT(errno); |
3563 } else { |
3594 } else { |
3564 # ifdef SO_REUSEADDR |
3595 # ifdef SO_REUSEADDR |
3565 if (reuse == true) { |
3596 if (reuse == true) { |
3724 ]. |
3755 ]. |
3725 %{ |
3756 %{ |
3726 #if defined(SO_RCVBUF) && defined(SOL_SOCKET) |
3757 #if defined(SO_RCVBUF) && defined(SOL_SOCKET) |
3727 if (__isSmallInteger(size)) { |
3758 if (__isSmallInteger(size)) { |
3728 OBJ fp = __INST(filePointer); |
3759 OBJ fp = __INST(filePointer); |
3729 int sock; |
3760 SOCKET sock; |
3730 int opt; |
3761 int opt; |
3731 |
3762 |
3732 sock = SOCKET_FROM_FILE_OBJECT(fp); |
3763 sock = SOCKET_FROM_FILE_OBJECT(fp); |
3733 opt = __intVal(size); |
3764 opt = __intVal(size); |
3734 if (setsockopt(sock, SOL_SOCKET, SO_RCVBUF, (char *)&opt, sizeof(int)) >= 0 ) { |
3765 if (setsockopt(sock, SOL_SOCKET, SO_RCVBUF, (char *)&opt, sizeof(int)) >= 0 ) { |
3753 millis := (seconds * 1000) rounded. |
3784 millis := (seconds * 1000) rounded. |
3754 %{ |
3785 %{ |
3755 #if defined(SO_RCVTIMEO) && defined(SOL_SOCKET) && defined(HZ) |
3786 #if defined(SO_RCVTIMEO) && defined(SOL_SOCKET) && defined(HZ) |
3756 if (__isSmallInteger(millis)) { |
3787 if (__isSmallInteger(millis)) { |
3757 OBJ fp = __INST(filePointer); |
3788 OBJ fp = __INST(filePointer); |
3758 int sock; |
3789 SOCKET sock; |
3759 int opt; |
3790 int opt; |
3760 |
3791 |
3761 sock = SOCKET_FROM_FILE_OBJECT(fp); |
3792 sock = SOCKET_FROM_FILE_OBJECT(fp); |
3762 opt = __intVal(millis) / (1000 / HZ); |
3793 opt = __intVal(millis) / (1000 / HZ); |
3763 if (setsockopt(sock, SOL_SOCKET, SO_RCVTIMEO, (char *)&opt, sizeof(int)) >= 0 ) { |
3794 if (setsockopt(sock, SOL_SOCKET, SO_RCVTIMEO, (char *)&opt, sizeof(int)) >= 0 ) { |
3805 ]. |
3836 ]. |
3806 %{ |
3837 %{ |
3807 #if defined(SO_SNDBUF) && defined(SOL_SOCKET) |
3838 #if defined(SO_SNDBUF) && defined(SOL_SOCKET) |
3808 if (__isSmallInteger(size)) { |
3839 if (__isSmallInteger(size)) { |
3809 OBJ fp = __INST(filePointer); |
3840 OBJ fp = __INST(filePointer); |
3810 int sock; |
3841 SOCKET sock; |
3811 int opt; |
3842 int opt; |
3812 |
3843 |
3813 sock = SOCKET_FROM_FILE_OBJECT(fp); |
3844 sock = SOCKET_FROM_FILE_OBJECT(fp); |
3814 opt = __intVal(size); |
3845 opt = __intVal(size); |
3815 if (setsockopt(sock, SOL_SOCKET, SO_SNDBUF, (char *)&opt, sizeof(int)) >= 0) { |
3846 if (setsockopt(sock, SOL_SOCKET, SO_SNDBUF, (char *)&opt, sizeof(int)) >= 0) { |
3834 millis := (seconds * 1000) rounded. |
3865 millis := (seconds * 1000) rounded. |
3835 %{ |
3866 %{ |
3836 #if defined(SO_SNDTIMEO) && defined(SOL_SOCKET) && defined(HZ) |
3867 #if defined(SO_SNDTIMEO) && defined(SOL_SOCKET) && defined(HZ) |
3837 if (__isSmallInteger(millis)) { |
3868 if (__isSmallInteger(millis)) { |
3838 OBJ fp = __INST(filePointer); |
3869 OBJ fp = __INST(filePointer); |
3839 int sock; |
3870 SOCKET sock; |
3840 int opt; |
3871 int opt; |
3841 |
3872 |
3842 sock = SOCKET_FROM_FILE_OBJECT(fp); |
3873 sock = SOCKET_FROM_FILE_OBJECT(fp); |
3843 opt = __intVal(millis) / (1000 / HZ); |
3874 opt = __intVal(millis) / (1000 / HZ); |
3844 if (setsockopt(sock, SOL_SOCKET, SO_SNDTIMEO, (char *)&opt, sizeof(int)) >= 0) { |
3875 if (setsockopt(sock, SOL_SOCKET, SO_SNDTIMEO, (char *)&opt, sizeof(int)) >= 0) { |
3863 #if defined(IPPROTO_TCP) && defined(TCP_CORK) |
3894 #if defined(IPPROTO_TCP) && defined(TCP_CORK) |
3864 int onOff = (aBoolean == true); |
3895 int onOff = (aBoolean == true); |
3865 |
3896 |
3866 if ((aBoolean == true) || (aBoolean == false)) { |
3897 if ((aBoolean == true) || (aBoolean == false)) { |
3867 OBJ fp = __INST(filePointer); |
3898 OBJ fp = __INST(filePointer); |
3868 int sock; |
3899 SOCKET sock; |
3869 int onOff = (aBoolean == true); |
3900 int onOff = (aBoolean == true); |
3870 |
3901 |
3871 sock = SOCKET_FROM_FILE_OBJECT(fp); |
3902 sock = SOCKET_FROM_FILE_OBJECT(fp); |
3872 if (setsockopt(sock, IPPROTO_TCP, TCP_CORK, (char *)&onOff, sizeof(int)) >= 0) { |
3903 if (setsockopt(sock, IPPROTO_TCP, TCP_CORK, (char *)&onOff, sizeof(int)) >= 0) { |
3873 RETURN(true); |
3904 RETURN(true); |
3891 #if defined(IPPROTO_TCP) && defined(TCP_NODELAY) |
3922 #if defined(IPPROTO_TCP) && defined(TCP_NODELAY) |
3892 int onOff = (aBoolean == true); |
3923 int onOff = (aBoolean == true); |
3893 |
3924 |
3894 if ((aBoolean == true) || (aBoolean == false)) { |
3925 if ((aBoolean == true) || (aBoolean == false)) { |
3895 OBJ fp = __INST(filePointer); |
3926 OBJ fp = __INST(filePointer); |
3896 int sock; |
3927 SOCKET sock; |
3897 int onOff = (aBoolean == true); |
3928 int onOff = (aBoolean == true); |
3898 |
3929 |
3899 sock = SOCKET_FROM_FILE_OBJECT(fp); |
3930 sock = SOCKET_FROM_FILE_OBJECT(fp); |
3900 if (setsockopt(sock, IPPROTO_TCP, TCP_NODELAY, (char *)&onOff, sizeof(int)) >= 0) { |
3931 if (setsockopt(sock, IPPROTO_TCP, TCP_NODELAY, (char *)&onOff, sizeof(int)) >= 0) { |
3901 RETURN(true); |
3932 RETURN(true); |