quasar@krazykat.ctt.bellcore.com (Laurence R. Brothers) (10/24/89)
First of all, let me apologize if this has come up before; I just started reading the group, and there were 3000 articles to catch up on.... Anyhow, taking my cue from the example on page 83 of the XView 1.0 Reference Manual: Converting SunView Applications, I wrote a program designed to open windows on two different machines simultaneously. (source is appended to this posting). Naturally, I ran xhost + on the appropriate machines beforehand. Curiously enough, the behavior I got was exactly the reverse of expected. Instead of opening one window on each of two remote machines, the program opened two (correctly functional) windows on my own machine. OK, I thought, so due to some bug, I just connected twice with my local server -- not good, but still comprehensible. But then, just as a test, I ran xhost - on the remote machines, and I immediately got the appropriate errors about being unable to connect to remote server foo, access denied, etc., when I tried to run my program, as if on remote displays as intended. In other words, it's as if the client-server relationship suddenly reversed, though of course it is impossible that my code suddenly migrated to the remote machines. Instead I suppose that in some sort of strange loop, my client application is sending two streams of X protocol out to remote servers, which for reasons of their own are turning around and beaming the damn things back at me to be interpreted by my local server.... Any clues? Am I just missing something obvious here? Is my code doing something stupid? This is version 1.0 FCS Open Windows running on a sun 4/260, incidentally. -Laurence quasar@ctt.bellcore.com =============================cut here=============================== /* this source is perhaps a little ornate for just the simple test, but I was intending to expand it to a more complex application.... */ #include <stdio.h> #include <string.h> #include <xview/xview.h> #include <xview/panel.h> #include <xview/notify.h> int death_counter=0; typedef struct remote_struct { Xv_Server server; Xv_Screen screen; Xv_Window root; Frame frame; Panel panel; } Remote; Remote remotes[2]; quit_proc(item,event) Panel_item item; Event *event; { int i = (int)xv_get(item,XV_KEY_DATA,0); Remote *r = remotes+i; xv_destroy_safe(r->frame); death_counter++; } init_root(name,i) int i; { Remote *r = remotes+i; char sname[128]; sprintf(sname,"%s:0",name); r->server = xv_find(NULL, SERVER, XV_NAME, sname, 0); r->screen = xv_get(r->server,SERVER_NTH_SCREEN,0); r->root = xv_get(r->server,XV_ROOT); r->frame = xv_create(r->root,FRAME,XV_WIDTH,200, FRAME_LABEL,sname,XV_HEIGHT,200,0); r->panel = xv_create(r->frame,PANEL,0); xv_create(r->panel,PANEL_BUTTON, XV_KEY_DATA,0, i, PANEL_LABEL_STRING, "Good-bye, world", PANEL_NOTIFY_PROC, quit_proc, 0); } main (argc,argv) int argc; char **argv; { xv_init(XV_INIT_ARGS, argc,argv,0); init_root("hostname1",0); init_root("hostname2",1); xv_set(remotes[0].frame,XV_SHOW,TRUE,0); xv_set(remotes[1].frame,XV_SHOW,TRUE,0); /* use explicit dispatching or xv_main_loop will only raise one of the two frames. Is this true or what? When I tried xv_main_loop the application refused to terminate on the destruction of the frame. */ while(death_counter < 2) { notify_dispatch(); } } Laurence R. Brothers (quasar@ctt.bellcore.com) Bellcore -- Computer Technology Transfer -- Knowledge-Based Systems Development "It's easier to try, than to prove it can't be done."