home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Amiga Format CD 28
/
amigaformatcd28.iso
/
-seriously_amiga-
/
comms
/
other
/
rxsocket
/
examples
/
echoudp.rexx
< prev
next >
Wrap
OS/2 REXX Batch file
|
1998-05-09
|
1KB
|
62 lines
/*
echo udp client - Usage: echoudp <host>
*/
parse arg host .
if ~show("L","rxsocket.library") then
if ~addLib("rxsocket.library",0,-30) then do
say "can't find rxsocket.library"
exit
end
if host="" || host="?" then do
say "Usage: echoudp <host>"
exit
end
addr = resolve(host)
if addr=="-1" then do
say "echoudp: no host <" || host || ">"
exit
end
if ~GetServByName("SE","echo","udp") then do
say "echoudp: no echo udp service"
exit
end
remote.addrFamily = "INET"
remote.addrAddr = addr
remote.addrPort = se.servPort
sock = socket("INET","DGRAM","IP")
if sock<0 then do
say "echoudp: no socket (" || errno() || ")"
exit
end
local.addrFamily = "INET"
local.addrAddr = 0
local.addrPort = 0
if bind(sock,"LOCAL")<0 then do
say "echoudp: bind error (" || errno() || ")"
exit
end
data = "echo udp service test"
n = SendTo(sock,data,0,"REMOTE")
if n<length(data) then do
say "echoudp: SendTo error (" || errno() || ")"
exit
end
len = RecvFrom(sock,"BUF",256,0,"REMOTE")
if len<0 then do
say "echoudp: recvfrom error (" || errno() || ")"
exit
end
say buf
call CloseSocket(sock)