HELP - Solaris9 & getpeername()

From: Oleg Yakovlev (yashka_at_optima.net.ua)
Date: 10/27/03


Date: Mon, 27 Oct 2003 09:12:43 +0200

Hi All!
I watch very strange behavior of the getpeername() in Solaris9. This
function returns sa_family=26 (IPV6) **ALWAYS**. I created short test
for it:

----------------------------- test.c -----------------------------------
#include <stdio.h>
#include <stdlib.h>
#include <sys/socket.h>
#include <errno.h>
#include <X11/Xatom.h>
#include <X11/Intrinsic.h>
#include <X11/Shell.h>

XtAppContext app_context;
Display *display; /* Display */

int main (int argc, char **argv) {
     char buf[512],*p;
     int len = sizeof(buf);
     p = buf;

     XtSetLanguageProc ( (XtAppContext) NULL, (XtLanguageProc) NULL,
(XtPointer) NULL );
     XtToolkitInitialize ();
     app_context = XtCreateApplicationContext ();
     display = XtOpenDisplay (app_context,NULL,argv[0],"TEST_IPV6",
                              NULL, 0, &argc, argv);
     if (!display) {
         fprintf(stderr,"%s: can't open display, exiting...\n", argv[0]);
         exit (-1);
     }

     if( getpeername(ConnectionNumber(display),(struct sockaddr
*)buf,&len) ) {
         fprintf(stderr,"ConnNum=%d:
%s\n",ConnectionNumber(display),strerror(errno));
         exit(0);
     }
     /* IP V6 ALWAYS!!!!! */
     printf("family=%d, len=%d\n",((struct sockaddr *)buf)->sa_family,len);

     XtCloseDisplay(display);
     exit (0);
}

I compile it with cc -I/usr/openwin/include -o test test.c -lXt -lsocket
Please, explain me what I doing wrong? The same binaries pretty works in
S7 & S8. This feature appears in S9 only :(

Thanks in advance,

-- 
Oleg N. Yakovlev, Dnepropetrovsk, Ukraine
http://www.yashka.dp.ua

Quantcast