$title('sndmsg - send a message to a known port') $compact sndmsg: DO; $include(:rmx:inc/rmxplm.ext) $include(dcom.ext) $include (dcom.lit) $include(:rmx:inc/error.lit) $include(err.ext) /******************************************************************** * * MODULE NAME: sndmsg * * DESCRIPTION: Create a data port and send a short message to a well-known * host and port. * *********************************************************************/ DECLARE /* Literals */ REMPORT LITERALLY '801H', /* Port id of remote port */ REMHOST LITERALLY '05', /* Host id of remote host, this must match hostid of remote agent */ CONBUF LITERALLY '16', /* size of a control buffer */ TSTPORT LITERALLY '801H', /* well-known port */ NOEXCEPT LITERALLY '0', /* no exception handling by system */ SFLAGS LITERALLY '00000B'; /* data buffer, synchronous flags*/ DECLARE /* Global vars */ status WORD, port_t TOKEN, /* Token for local port */ messock socket, /* socket to which message is sent */ msock DWORD AT (@messock), /* dword alias for messock */ con_buf (CONBUF) BYTE, /* control buffer */ mess_size DWORD, /* number of bytes in data message */ bpool TOKEN, /* buffer pool attached to port */ trans_id WORD, /* transaction id */ mes_buf(*) BYTE INITIAL (26,'This is a simple message',0dh,0ah); CALL set$exception(NOEXCEPT); port_t = get$dport(TSTPORT, @bpool, CHAIN, @status); messock.host_id = REMHOST; messock.port_id = REMPORT; mess_size = size(mes_buf); trans_id = rq$send(port_t,msock, @con_buf, @mes_buf, mess_size, SFLAGS, @status); CALL error$check(100, status); CALL rq$exit$io$job(0,NIL,@status); END sndmsg;