Re: Squid Socket question

From: Guido Serassio <serassio@dont-contact.us>
Date: Wed, 22 Aug 2001 21:19:56 +0200

Hi,

Il 00.45 22/08/2001 Henrik Nordstrom ha scritto:
>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.

The only sure thing about this is that Microsoft Winsock 2 don't like "0",
but can we be sure that IPPROTO_UDP and IPPROTO_TCP defines works fine on
ALL Squid *nix platforms ? I think NO, and you write "The exact meaning is
implementation dependent" ... very dangerous .....
So, I think that the most conservative approach is 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

We can add non "0" working platforms with time ...
Can be that defines can help work on IPV6, there is anyone that know
something about this ?

Guido

>--
>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.it
Received on Wed Aug 22 2001 - 13:26:55 MDT

This archive was generated by hypermail pre-2.1.9 : Tue Dec 09 2003 - 16:14:15 MST