|
From: Samuel L. B. <sa...@mi...> - 2002-04-30 15:09:16
|
I am trying to build a Hub Client.
It is supposed to have an open port, which receives connection using a
common TCP-IP socket. For each accept connection it will create a child
(fork), on this child i would like to read the message from the socket,
connect to the hub send the message, receive the reply send it throw the
socket and close all connections and exit.
I wanted to set the server with GalSS_cmdlineSetupServer... but when i
call GalSS_StartandRunServer i lose the control, because all the
interection with reinitialize and the time task loop begins... Is it
possible to simply start the server, send the message, await for reply
and then shut down... How can this be done?
This is one of the things we need to fix for 4.0. There's a simple way
to contact a server pretending to be the Hub (GalIO_ClientConnect),
but not necessarily a simple way of contacting the Hub as a
server. Try this:
GalIO_ServerStruct *server;
GalIO_CommStruct *new_comm;
GalSS_Environment *env;
server = GalSS_CmdlineSetupServer(argc, argv);
if (!server) {
GalUtil_Fatal("Failed to set up server!\n");
}
/* Assuming you have the host, port, and you've determined
what your poll flags are (see the documentation for
GalIO_ServerListenStatus) */
new_comm = GalIO_ContactHub(host, port, server, (char *) NULL,
poll_flags);
/* At this point, you should be able to send a message to the
Hub and get its reply using GalSS_EnvDispatchFrame(). */
env = GalSS_EnvCreate(new_comm);
GalSS_EnvLock(env);
/* build your message, get the reply. */
reply = GalSS_EnvDispatchFrame(env, ....);
GalSS_EnvUnlock(env);
/* etc. More cleanup: free frames, destroy the connection and
server. */
This ought to be a little simpler, and it ought to be in the docs. If
this doesn't work, send more mail to this list or to
bug...@li... and we'll work it out.
Cheers,
Sam Bayer
|