home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Amiga Format CD 28
/
amigaformatcd28.iso
/
-seriously_amiga-
/
comms
/
other
/
rxsocket
/
examples
/
pserv.rexx
< prev
next >
Wrap
OS/2 REXX Batch file
|
1998-05-09
|
877b
|
38 lines
/*
A simple inetd service example.
it waits for a string of max 256 char len and send it back reversed.
If the clip PSERV_LOG in equal to 1, the connection is logged.
*/
/* socket is number 0 */
if ~IsSocket(0) then do
say "this service must be run from rxs in inedt"
exit
end
/* who is it? */
if ~GetSockName(0,"NAME")<0 then do
call SysLog("pserv Can't get peer info (" || errno() || ")")
exit
end
if getclip("PSERV_LOG")==1 then do
/* log the connection */
msg = "pserv Connection from" name.addrAddr
if GetHostByAddr("HOST",name.addrAddr) then msg = msg "(" || host.hostName || ")"
call SysLog(msg)
end
/* the service itself */
len = recv(0,"BUF",256)
if len<0 then do
call SysLog("pserv Error reading (" || errno() || ")")
exit
end
buf = reverse(buf)
if send(0,BUF)~=length(buf) then do
call SysLog("pserv Error sending (" || errno() || ")")
exit
end