Changeset 2946


Ignore:
Timestamp:
Oct 15, 2009 3:48:20 AM (10 years ago)
Author:
bennylp
Message:

Ticket #972: setsockopt compatibility problems on Windows (thanks Yann and John Ridges for the reports)

  • set PJ_SOL_IP, PJ_SOL_TCP, and PJ_SOL_UDP to IPPROTO_IP, IPPROTO_TCP, and IPPROTO_UDP respectively on Windows
  • also added PJ_TCP_NODELAY and PJ_SO_REUSEADDR
Location:
pjproject/trunk/pjlib
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • pjproject/trunk/pjlib/include/pj/sock.h

    r2863 r2946  
    291291extern const pj_uint16_t PJ_SO_SNDBUF; 
    292292 
     293/** Disables the Nagle algorithm for send coalescing. @see pj_TCP_NODELAY */ 
     294extern const pj_uint16_t PJ_TCP_NODELAY; 
     295 
     296/** Allows the socket to be bound to an address that is already in use. 
     297 *  @see pj_SO_REUSEADDR */ 
     298extern const pj_uint16_t PJ_SO_REUSEADDR; 
     299 
    293300/** IP multicast interface. @see pj_IP_MULTICAST_IF() */ 
    294301extern const pj_uint16_t PJ_IP_MULTICAST_IF; 
     
    317324    PJ_DECL(pj_uint16_t) pj_SO_SNDBUF(void); 
    318325 
     326    /** Get #PJ_TCP_NODELAY constant */ 
     327    PJ_DECL(pj_uint16_t) pj_TCP_NODELAY(void); 
     328 
     329    /** Get #PJ_SO_REUSEADDR constant */ 
     330    PJ_DECL(pj_uint16_t) pj_SO_REUSEADDR(void); 
     331 
    319332    /** Get #PJ_IP_MULTICAST_IF constant */ 
    320333    PJ_DECL(pj_uint16_t) pj_IP_MULTICAST_IF(void); 
     
    340353    /** Get #PJ_SO_SNDBUF constant */ 
    341354#   define pj_SO_SNDBUF()   PJ_SO_SNDBUF 
     355 
     356    /** Get #PJ_TCP_NODELAY constant */ 
     357#   define pj_TCP_NODELAY() PJ_TCP_NODELAY 
     358 
     359    /** Get #PJ_SO_REUSEADDR constant */ 
     360#   define pj_SO_REUSEADDR() PJ_SO_REUSEADDR 
    342361 
    343362    /** Get #PJ_IP_MULTICAST_IF constant */ 
  • pjproject/trunk/pjlib/src/pj/sock_bsd.c

    r2394 r2946  
    6161#ifdef SOL_IP 
    6262const pj_uint16_t PJ_SOL_IP     = SOL_IP; 
     63#elif defined(PJ_WIN32) && PJ_WIN32 
     64const pj_uint16_t PJ_SOL_IP     = IPPROTO_IP; 
    6365#else 
    6466const pj_uint16_t PJ_SOL_IP     = 0xFFFF; 
    6567#endif /* SOL_IP */ 
     68 
    6669#if defined(SOL_TCP) 
    6770const pj_uint16_t PJ_SOL_TCP    = SOL_TCP; 
    6871#elif defined(IPPROTO_TCP) 
    6972const pj_uint16_t PJ_SOL_TCP    = IPPROTO_TCP; 
     73#elif defined(PJ_WIN32) && PJ_WIN32 
     74const pj_uint16_t PJ_SOL_TCP    = IPPROTO_TCP; 
    7075#else 
    7176const pj_uint16_t PJ_SOL_TCP    = 0xFFFF; 
    7277#endif /* SOL_TCP */ 
     78 
    7379#ifdef SOL_UDP 
    7480const pj_uint16_t PJ_SOL_UDP    = SOL_UDP; 
     81#elif defined(PJ_WIN32) && PJ_WIN32 
     82const pj_uint16_t PJ_SOL_UDP    = IPPROTO_UDP; 
    7583#else 
    7684const pj_uint16_t PJ_SOL_UDP    = 0xFFFF; 
    77 #endif 
     85#endif /* SOL_UDP */ 
     86 
    7887#ifdef SOL_IPV6 
    7988const pj_uint16_t PJ_SOL_IPV6   = SOL_IPV6; 
     89#elif defined(PJ_WIN32) && PJ_WIN32 
     90const pj_uint16_t PJ_SOL_IPV6   = IPPROTO_IPV6; 
    8091#else 
    8192const pj_uint16_t PJ_SOL_IPV6   = 0xFFFF; 
    82 #endif 
     93#endif /* SOL_IPV6 */ 
    8394 
    8495/* IP_TOS */ 
     
    117128const pj_uint16_t PJ_SO_RCVBUF  = SO_RCVBUF; 
    118129const pj_uint16_t PJ_SO_SNDBUF  = SO_SNDBUF; 
     130const pj_uint16_t PJ_TCP_NODELAY= TCP_NODELAY; 
     131const pj_uint16_t PJ_SO_REUSEADDR= SO_REUSEADDR; 
     132 
    119133/* Multicasting is not supported e.g. in PocketPC 2003 SDK */ 
    120134#ifdef IP_MULTICAST_IF 
  • pjproject/trunk/pjlib/src/pj/sock_common.c

    r2886 r2946  
    10631063} 
    10641064 
     1065PJ_DEF(pj_uint16_t) pj_TCP_NODELAY(void) 
     1066{ 
     1067    return PJ_TCP_NODELAY; 
     1068} 
     1069 
     1070PJ_DEF(pj_uint16_t) pj_SO_REUSEADDR(void) 
     1071{ 
     1072    return PJ_SO_REUSEADDR; 
     1073} 
     1074 
    10651075PJ_DEF(pj_uint16_t) pj_IP_MULTICAST_IF(void) 
    10661076{ 
  • pjproject/trunk/pjlib/src/pj/sock_symbian.cpp

    r2771 r2946  
    4848const pj_uint16_t PJ_SOCK_RDM   = 0xFFFF; 
    4949 
    50 /* setsockop() is not really supported. */ 
     50/* we don't support setsockopt(), these are just dummy values */ 
    5151const pj_uint16_t PJ_SOL_SOCKET = 0xFFFF; 
    5252const pj_uint16_t PJ_SOL_IP     = 0xFFFF; 
     
    6161const pj_uint16_t PJ_IPTOS_RELIABILITY  = 0; 
    6262const pj_uint16_t PJ_IPTOS_MINCOST      = 0; 
     63 
     64/* Misc */ 
     65const pj_uint16_t PJ_TCP_NODELAY = 0xFFFF; 
     66const pj_uint16_t PJ_SO_REUSEADDR = 0xFFFF; 
    6367 
    6468/* ioctl() is also not supported. */ 
  • pjproject/trunk/pjlib/src/pjlib-test/sock.c

    r2863 r2946  
    168168    /* pj_gethostaddr() */ 
    169169 
     170    /* Various constants */ 
     171#if !defined(PJ_SYMBIAN) || PJ_SYMBIAN==0 
     172    if (PJ_SOL_IP==0xFFFF) return -5500; 
     173    if (PJ_SOL_TCP==0xFFFF) return -5510; 
     174    if (PJ_SOL_UDP==0xFFFF) return -5520; 
     175    if (PJ_SOL_IPV6==0xFFFF) return -5530; 
     176 
     177    if (PJ_SO_TYPE==0xFFFF) return -5540; 
     178    if (PJ_SO_RCVBUF==0xFFFF) return -5550; 
     179    if (PJ_SO_SNDBUF==0xFFFF) return -5560; 
     180    if (PJ_TCP_NODELAY==0xFFFF) return -5570; 
     181    if (PJ_SO_REUSEADDR==0xFFFF) return -5580; 
     182 
     183    if (PJ_MSG_OOB==0xFFFF) return -5590; 
     184    if (PJ_MSG_PEEK==0xFFFF) return -5600; 
     185#endif 
    170186 
    171187    return 0; 
Note: See TracChangeset for help on using the changeset viewer.