context | the real application using the libFreiburg 2.0 interface and service handles |
client | the part of the software doing the connect system-call |
server | the part of the software doing the accept system-call (e.g. service) |
parent | the first context of a client / server pair |
child | the second or more context of the parent - client / server pair |
*- client21 -> server21
|-> server11 -*
| *- client22 -> server22
client1 -|
| *- client23 -> server23
|-> server12 -*
*- client24 -> server24
struct MqTokenS * const srvT = msgque->srvT; // get the 'srvT' member of the MqS object MqErrorCheck(MqTokenAddHdl(srvT, "TOK2", proc2, data2); // add TOK2 as service handle MqErrorCheck(MqTokenDelHdl(srvT, "TOK2"); // delete TOK2 as service handle
$Ctx service create TOK2 tclProc2; ## add TOK2 as service handle $Ctx service delete TOK2; ## delete TOK2 as service handle
static MqErrorE pMYDO(MqSP const msgque, MQ_PTR data) { MqReadSP const read = msgque->read; MqSendSP const send = msgque->send; MqBufferSP buf; // buffer space MqErrorCheck (MqReadU (read, &buf)); // read next item into buffer object MqSendSTART (send); // reset the send object MqSendC (send,pDoSomeUsefullThings(buf)); // append string item return MqSendEND_RETR (send,NULL); // send answer back error: // used by MqErrorCheck return MqSendRETURN(send,MQ_ERROR_PROC_FMT,__func__); } // read command-line: -name Ars -tcp -inetd -host arsHost -port arsservice MqBufferLSP argv = MqBufferLCreateArgv(NULL, --argc, ++argv); MqBufferLAppendH2(argv, "-type", MQ_CLIENT); // using 'client' behavior MqErrorCheck(MqCreate(context, argv, &context->msgque)); // create the 'Freiburg' object MqTokenSP const token = context->msgque->srvT; // get the 'service' token MqErrorCheck(MqTokenAddHdl(token, "MYDO", pMYDO, NULL)); // set the 'MYDO' service handle
set Ctx [tclFreiburg::Start -name Ars -tcp -inetd -host arsHost -port arsservice]
proc ProvideSomeData {Ctx} {
$Ctx send -retcode ok MYD0 [DoSomeUsefullThings [$Ctx read next]]
}
$Ctx service create MYD0 ProvideSomeData;
// read command-line: -name MyApplication MqBufferLSP argv = MqBufferLCreateArgv(NULL, --argc, ++argv); MqBufferLAppendH2(argv, "-type", MQ_CLIENT); // using 'client' behavior MqErrorCheck(MqCreate(context, argv, &context->msgque)); // create the 'Freiburg' object
set Ctx [tclFreiburg::Start -name MyApplication];
MqDelete(&context->msgque);
rename $CTX "";
set Ctx [tclFreiburg::Start -name MyApplication -uds]; # using '-uds' communication set Ctx [tclFreiburg::Start -name MyApplication -tcp]; # using '-tcp' communication
set Ctx [tclFreiburg::Start -name MyApplication -tcp -inetd -host myHost -port myPort];
| option | type | default | description |
| -name | STR | "noname" | the name of the application |
| -type | INT | MQ_CLIENT | MqE type of the application |
| -debug | INT | 0 | debug level (0-9) |
| -stat | INT | 0 | statistics level (0-9) |
| -parent | ID | NULL | create as CHILD of parent |
| -string | BOOL | no | convert every non-binary MqTypeE data to string |
| -silent | BOOL | no | be silent? |
| -inetd | BOOL | no | remote mode: using inetd to start the server? |
| -timeout | INT | system | timeout seconds to wait for connection |
| -server | STR | NULL | local mode: path to the server |
| -uds | BOOL | yes | use UDS style communication? |
| -file | STR | random | UDS file name |
| -tcp | BOOL | no | use TCP style communication? |
| -host | STR | localhost | server TCP host-name |
| -port | STR | random | server TCP port as number or string |
| -myhost | STR | NULL | client TCP host-name |
| -myport | STR | NULL | client TCP port as number or string |
| -fCreate | POINTER | NULL | the ContextCreate procedure |
| -fDelete | POINTER | NULL | the ContextDelete procedure |
| -fevent | POINTER | NULL | procedure to call external event-queue |
| -id | STRING | INTERNAL | local mode: used for internal purpose |
tclFreiburg::Start -name Ars -uds -server ArsService.exe
arsservice 16790/tcp # ARS application server as 'Freiburg' service
arsservice stream tcp nowait arsuser /path/to/the/ArsService.exe ArsService -inetd -tcp
ArsServer1 ArsServer2
| |
ArsService(local) ArsService(arsHost:arsPort)
| |
|Parent1 Parent2|
^--------tclFreiburg---------^
set Parent1 [tclFreiburg::Start -name Ars -uds];
set Parent2 [tclFreiburg::Start -name Ars -tcp -inetd -host arsHost -port arsPort];
ArsServer1 ArsServer2
| |
^---------ArsService---------^
<-- | | -->
parent child
| |
tclFreiburg
set Ctx [tclFreiburg::Start -name Ars -uds]; # I'm a parent set Cl1 [tclFreiburg::Start -parent $Ctx]; # I'm a child set Cl2 [tclFreiburg::Start -parent $Ctx]; # I'm an other child set Cl3 [tclFreiburg::Start -parent $Cl1]; # I'm an other child, even if my '-parent' is a child
1.3.8-20040928