Changeset 4860 for pjproject/trunk/pjlib/src/pj/sock_bsd.c
- Timestamp:
- Jun 19, 2014 5:07:12 AM (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
pjproject/trunk/pjlib/src/pj/sock_bsd.c
r4537 r4860 27 27 #include <pj/unicode.h> 28 28 29 #define THIS_FILE "sock_bsd.c" 30 29 31 /* 30 32 * Address families conversion. … … 766 768 int optlen) 767 769 { 768 PJ_CHECK_STACK(); 769 if (setsockopt(sock, level, optname, (const char*)optval, optlen) != 0) 770 int status; 771 PJ_CHECK_STACK(); 772 773 #if (defined(PJ_WIN32) && PJ_WIN32) || (defined(PJ_SUNOS) && PJ_SUNOS) 774 /* Some opt may still need int value (e.g:SO_EXCLUSIVEADDRUSE in win32). */ 775 status = setsockopt(sock, 776 level, 777 ((optname&0xff00)==0xff00)?(int)optname|0xffff0000:optname, 778 (const char*)optval, optlen); 779 #else 780 status = setsockopt(sock, level, optname, (const char*)optval, optlen); 781 #endif 782 783 if (status != 0) 770 784 return PJ_RETURN_OS_ERROR(pj_get_native_netos_error()); 771 785 else 772 786 return PJ_SUCCESS; 787 } 788 789 /* 790 * Set socket option. 791 */ 792 PJ_DEF(pj_status_t) pj_sock_setsockopt_params( pj_sock_t sockfd, 793 const pj_sockopt_params *params) 794 { 795 unsigned int i = 0; 796 pj_status_t retval = PJ_SUCCESS; 797 PJ_CHECK_STACK(); 798 PJ_ASSERT_RETURN(params, PJ_EINVAL); 799 800 for (;i<params->cnt && i<PJ_MAX_SOCKOPT_PARAMS;++i) { 801 pj_status_t status = pj_sock_setsockopt(sockfd, 802 (pj_uint16_t)params->options[i].level, 803 (pj_uint16_t)params->options[i].optname, 804 params->options[i].optval, 805 params->options[i].optlen); 806 if (status != PJ_SUCCESS) { 807 retval = status; 808 PJ_PERROR(4,(THIS_FILE, status, 809 "Warning: error applying sock opt %d", 810 params->options[i].optname)); 811 } 812 } 813 814 return retval; 773 815 } 774 816
Note: See TracChangeset
for help on using the changeset viewer.