0

I am getting problem while running following program over Solaris 11. The XOpenDisplay function always return NULL. The same program run fine over Solaris 10.

#include <stdio.h>
#include <X11/Xlib.h>

int main(int argc, char** argv) {
    Display *ptr = 0;


    ptr = XOpenDisplay("machine_name:0.0");

    if (0 == ptr)
    {
        printf("NULL received\n");
    }
    else
    {
        printf("Valid pointer received\n");
    }

    return 0;
}

During investigation I have found that the Solaris 11 do not accept direct X11 connections by using the TCP protocol. I have enabled the TCP for X11-server using the following command.

svccfg -s x11-server setprop options/tcp_listen=true

But during calling the function XOpenDisplay still returns the NULL and now I am getting the error as "no protocol specified".

Sumeet
  • 779
  • 6
  • 20

1 Answers1

0

Can you open a connection with a simple X client such as xclock or xdpyinfo with $DISPLAY set to machine_name:0.0 - until you can do that, you have a configuration error in your X setup, and need to fix that before you can find if your code is working or not.

Are you logged into the X session on the Solaris 11 machine? Did it store the xauth cookies in $HOME/.Xauthority or is it using the new gdm default of setting $XAUTHORITY to a local file in /tmp that isn't visible to other machines? If so, you may need to copy the xauth cookie for that machine to $HOME/.Xauthority or a file on the remote system that you set $XAUTHORITY to point to.

BTW, we mainly recommend using ssh -X to make remote X connections these days, and to take care of setting the DISPLAY environment variable, xauth cookies, and handling security for you, so you don't have to do that all yourself.

alanc
  • 4,102
  • 21
  • 24
  • :I have logged directly into the X session on Solaris 11. My application is running over the same host machine and opening the connection with same host using hostname:0.0. If I give the command ssh -X username@host_name then the application runs properly and able to open the connection with X server. But I have to give this command every time I open the new terminal. How should I configure the authentication using .Xauthority? Do you have any oracle link for sharing? – Sumeet Apr 11 '13 at 12:24