Gethostname function call problem
PROBLEM:
PROBLEM:
When using gethostname function to retrieve hostname, sometimes it returns xliblocalhost instead of current host name.
SOLUTION:
You need to open a connection to make gethostname function working properly.
Add the following lines to the code before calling gethostname and the problem will be fixed:
#include <X11/Xlib.h>
.....
Display *dpy = XOpenDisplay(NULL);


Print View
Contact Me