Skip to Content.
Sympa Menu

freetds - Re: [freetds] Getting it to all work on HPUX

freetds AT lists.ibiblio.org

Subject: FreeTDS Development Group

List archive

Chronological Thread  
  • From: Frediano Ziglio <freddy77 AT gmail.com>
  • To: FreeTDS Development Group <freetds AT lists.ibiblio.org>
  • Subject: Re: [freetds] Getting it to all work on HPUX
  • Date: Mon, 9 Feb 2009 16:41:11 +0100

2009/2/9 Christos Zoulas <christos AT zoulas.com>:
> On Feb 9, 11:34am, freddy77 AT gmail.com (Frediano Ziglio) wrote:
> -- Subject: Re: [freetds] Getting it to all work on HPUX
>
> | 2009/2/7 Christos Zoulas <christos AT zoulas.com>:
> | > On Feb 6, 9:45pm, jklowden AT freetds.org ("James K. Lowden") wrote:
> | > -- Subject: Re: [freetds] Getting it to all work on HPUX
> | >
> | > | Frediano Ziglio wrote:
> | > | > > I think we should use an autoconf test to detect the presence of
> | > | > > socklen_t instead of resorting to such ugliness .
> | > | > >
> | > | >
> | > | > We already test for socklen_t. The problem is that HP-UX use
> | > | > socklen_t* for last getsockopt argument in some cases and int in
> some
> | > | > others (giving different defines).
> | > |
> | > | It reminds me of the gethostbyname_r fiasco. Solvable with autoconf,
> but
> | > | not pretty. Perhaps another project has already written the
> approprite
> | > | m4?
> | >
> | > Look in the tcsh's configure.in. Thank you HP *again*!
> | >
> | > christos
> |
> | I don't see nothing about getsockopt in tcsh's configure.in, only
> | about socklen_t (which we already test in our configure script). The
> | problem is not socklen_t but the use of it in getsockopt !!
> | Yes, my workaround is ugly...
>
> And it will not work for big-endian _LP64 machines where socklen_t is
> 32bits.
> I don't know if any such beasts exist. Let me try to find a getsockopt test.
>
> christos

Just to make you smyle....

Take this program

#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <string.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <errno.h>

int main()
{
int error;
int res;
union {
int i;
socklen_t l;
int arr[2];
} len;

int sock = socket(PF_INET, SOCK_STREAM, 0);
if (sock < 0) {
fprintf(stderr, "socket error\n");
return 1;
}

memset(&len, 0xcc, sizeof(len));
len.l = sizeof(error);
error = -1;
res = getsockopt(sock, SOL_SOCKET, SO_ERROR, &error, &len);
printf("res %d error %d errno %d(%s)\n", res, error, errno,
strerror(errno));
printf("%08x%08x\n", len.arr[0], len.arr[1]);

memset(&len, 0xcc, sizeof(len));
len.i = sizeof(error);
error = -1;
res = getsockopt(sock, SOL_SOCKET, SO_ERROR, &error, &len);
printf("res %d error %d errno %d(%s)\n", res, error, errno,
strerror(errno));
printf("%08x%08x\n", len.arr[0], len.arr[1]);
return 0;
}

$ hppa64-hp-hpux11.00-gcc -Wall -O2 -s -o getsockopt.hp getsockopt.c
$ ./getsockopt.hp
res 0 error -1 errno 0(Error 0)
0000000000000004
res 0 error 0 errno 0(Error 0)
00000004cccccccc

$ hppa64-hp-hpux11.00-gcc -Wall -O2 -s -o getsockopt.hp getsockopt.c
-lxnet -lnsl
$ ./getsockopt.hp
res 0 error 0 errno 0(Error 0)
0000000000000004
res 0 error 0 errno 0(Error 0)
0000000000000004

:)

Have you noted?? libc getsockopt use a 32bit while xnet version of the
same function use 64bit. In this version (I used 11.11 parisc) it
seems to ignore input length (or assume it's ok) but doesn't set
*optval while second set correctly *optval and *optlen. So... are you
sure my code is so ugly ?? Probably however in my case tds function
will report always success :( Perhaps newer version give EINVAL for
int* version so my code should work.

freddy77




Archive powered by MHonArc 2.6.24.

Top of Page