test_socket.py failure
x2164 at mailcity.com
x2164 at mailcity.com
Fri Feb 4 10:12:22 EST 2005
Nick Coghlan <ncoghlan at iinet.net.au> wrote:
> x2164 at mailcity.com wrote:
> > Marc, it is possible that there was a change between
> > glibc-2.2.4 and 2.2.5 that would account for the
> > difference in behaviour. I think i'll write a little
> > test program in C to check out getservbyname's return
> > values in a little more controled environment. I'll
> > post the results tomorrow.
> The other question is which C library Python is actually
> using on your system.
> Maybe it's picking up whatever installed the funky man page
> which doesn't
> mention NULL proto arguments.
> So, find your Python 2.4 binary and run "ldd python24" to
> see which shared C
> library it is linking to.
> For me, it's /lib/tls/libc.so.6. Running that library directly
> prints out the
> message about GNU C library 2.3.3.
hey Nick,
The man pages are probably from orignal system installation
so i used your ldd technique which says that the python
executable was compiled against glibc-2.2.5.
I'm going to check the diff for 2.2.4-2.2.5 and look for
anything getservbyname related.
Below i'm including the source code for a little
program to exercise getservbyname. On this system
if 'NULL' is passed as the protocal then 'NULL' is
returned.
I wonder if writing some code around the call to
getservbyname in Modules/socketmodule.c to test
for a call with the NULL argument would be
appropriate. Could you show the output from my
included program when NULL is passed as
an argument? Probably would be good to know
what the call returns on your system before
trying to get mine to mimic it.
Ok, back to grep'ing.
pete jordan
x2164 mailcity com
/*
* This program just test what happens when getservbyname
* is passed a NULL pointer argument for the name and proto
* paramenters.
*
* The compilation line i used:
*
* gcc getserv.c -o getserv
*
* and just type 'getserv' at a prompt.
*
* Just pass 'service name, protocol name' to
* 'get_print' to check if combination is found.
*/
#include <stdio.h>
#include <netdb.h>
#include <netinet/in.h>
void get_print( const char *, const char * );
int main()
{
get_print( "daytime", "tcp" );
get_print( "daytime", "udp" );
get_print( "daytime", NULL );
get_print( NULL, "tcp" );
get_print( NULL, NULL );
get_print( "ithkl", "tcp" );
get_print( "echo", "ddp" );
return ;
}
void get_print( const char *name, const char *proto )
{
struct servent *result = NULL ;
result = getservbyname( name, proto );
printf( "\n getservbyname call: getservbyname( %s , %s ) \n",
name, proto );
printf(" getservbyname returned:\n");
if ( result == NULL )
printf("\t\t\t NULL - end of 'services' file reached or\n"
"\t\t\t error occured.\n\n");
else
{
printf( "\t\t\t s_name = %s \n", result->s_name );
printf( "\t\t\t s_port = %d \n", ntohs(result->s_port) );
printf( "\t\t\t s_proto = %s \n", result->s_proto );
printf( "\n" );
}
}
More information about the Python-list
mailing list