On all platforms it should be safe to use IPPROTO_UDP/TCP if defined, 0 if not.
...
#ifdef IPPROTO_UDP
IPPROTO_UDP,
#else
0,
#endif
...
On UNIX protocol 0 is defined as "best match for the socket type and domain". The
exact meaning is implementation dependent, but for IPv4 there isn't very much to
select between.
-- Henrik Guido Serassio wrote: > Hi Guys, > > I have the following question related to Squid native Windows NT port, not > Cygwin: > > Looking on the work of Romeo Anghelache on NT 2.3 native port, I found many > code sections like this: > > DnsSocket = comm_open(SOCK_DGRAM, > #ifdef _SQUID_MSWIN_ > IPPROTO_UDP, > #else > 0, > #endif > Config.Addrs.udp_outgoing, > 0, > COMM_NONBLOCKING, > "DNS Socket"); > > fd = comm_open(SOCK_STREAM, > #ifdef _SQUID_MSWIN_ > IPPROTO_TCP, > #else > 0, > #endif > s->s.sin_addr, > ntohs(s->s.sin_port), > COMM_NONBLOCKING, > "HTTP Socket"); > > The question is: > > Can be possible to substitute all "0" with the corresponding IPPROTO_UDP & > IPPROTO_TCP defines ? > Can work this on all *nix Systems ? > I can find these defines on Linux and Cygwin, but I don't know if this is > true on all supported *nix platforms. > > A possible variant can be: > > On squid.h (or config.h) like this: > > #ifdef _SQUID_MSWIN_ > #define SQUID_IPPROTO_TCP IPPROTO_TCP > #define SQUID_IPPROTO_UDP IPPROTO_UDP > #else > #define SQUID_IPPROTO_TCP 0 > #define SQUID_IPPROTO_UDP 0 > #endif > > And on c sources like this: > > DnsSocket = comm_open(SOCK_DGRAM, > SQUID_IPPROTO_UDP, > Config.Addrs.udp_outgoing, > 0, > COMM_NONBLOCKING, > "DNS Socket"); > > fd = comm_open(SOCK_STREAM, > SQUID_IPPROTO_TCP, > s->s.sin_addr, > ntohs(s->s.sin_port), > COMM_NONBLOCKING, > "HTTP Socket"); > > Thanks for Your comments. > > Guido > > - > ======================================================= > Serassio Guido > Via Albenga, 11/4 10134 - Torino - ITALY > Tel. : +39.011.610749 > E-mail: serassio@interfree.it > serassio@libero.it > WWW: http://www.serassio.itReceived on Tue Aug 21 2001 - 18:03:10 MDT
This archive was generated by hypermail pre-2.1.9 : Tue Dec 09 2003 - 16:14:14 MST