<div style="line-height:1.7;color:#000000;font-size:14px;font-family:arial"><DIV>Hello, every one.</DIV>
<DIV> This days I am studying the oldest version of x-window realization, with the purpose of getting a insight of the internal machanism. From the website of x.org.I picked up X.V10R3 to get start of my work.</DIV>
<DIV> My pc is now working with i386 arch and Fedora15 linux desktop system, which of that X.V10R3 not supported. So first i must rebuild Xlib.To test with a x-client program, the XOpenDisplay fucntion gave a "connect to x server error.". Things like this:</DIV>
<DIV> </DIV>
<DIV>I derectly test with the x-server on Fedora15.So i needn't wrote a xserver program first.</DIV>
<DIV> </DIV>
<DIV> </DIV>
<DIV>Using the DISPLAY :0.0</DIV>
<DIV>struct sockaddr_in inaddr; /* INET socket address. */<BR>struct sockaddr *addr; /* address to connect to */<BR>char displaybuf[256];</DIV>
<DIV>int addrlen; /* length of address */<BR>int indian; /* to determine which indian. */<BR>int fd;<BR>struct hostent *host_ptr;<BR>register XReq *req; /* XReq request packet pointer. */<BR>XRep rep; /* XRep reply packet. */<BR> <BR>gethostname(displaybuf, sizeof (displaybuf)); /* get local host name ˇ°localehost.localdomainˇ± */<BR>/* Get the statistics on the specified host. */<BR>if ((host_ptr = gethostbyname(displaybuf)) == NULL) <BR>{<BR> /* No such host! */<BR> errno = EINVAL;<BR> <BR> return(NULL);<BR>}<BR> /* Check the address type to see if it is an internet host. */<BR> if (host_ptr->h_addrtype != AF_INET) {<BR> /* Not an Internet host! */<BR> errno = EPROTOTYPE;</DIV>
<DIV> return(NULL);<BR> }<BR> <BR> /* Set up the socket data. */<BR> inaddr.sin_family = AF_INET;<BR> inaddr.sin_port = 0;<BR> indian = 1;<BR> if (*(char *) &indian)<BR> {<BR> inaddr.sin_port += 5800;<BR> }<BR> else<BR> {<BR> inaddr.sin_port += 5900;<BR> }<BR> inaddr.sin_port = htons(inaddr.sin_port); <BR> inaddr.sin_addr = *((struct in_addr *)host_ptr->h_addr);<BR> <BR> addr = (struct sockaddr *) &inaddr;<BR> addrlen = sizeof (struct sockaddr_in);</DIV>
<DIV> }<BR> <BR> if((fd = socket(addr->sa_family, SOCK_STREAM, 0)) < 0) <BR> {<BR> /* Socket call failed! */<BR> /* errno set by system call. */<BR> fprintf(stderr, "socket create error! \n");<BR> return(NULL);<BR> }<BR> <BR> /* Open the connection to the specified X server. */<BR> if(connect(fd, addr, addrlen) == -1) <BR> {<BR> /* Connection call failed! */<BR> /* errno set by system call. */</DIV>
<DIV> fprintf(stderr, "socket connect error.\n");<BR> return(NULL);<BR> }<BR>}</DIV>
<DIV> </DIV>
<DIV>By myself, I have two reason for this:</DIV>
<DIV>1.x-server needs a authentication that my test program didn't add.<BR> 2. In the program of mine, the port which i tried to connect is not a correct one.</DIV>
<DIV> </DIV>
<DIV>If someone known these things real, please give me a instructing.</DIV>
<DIV>Thanks very much.</DIV>
<DIV> </DIV></div><br><br><span title="neteasefooter"><span id="netease_mail_footer"></span></span>