home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Amiga Format CD 28
/
amigaformatcd28.iso
/
-seriously_amiga-
/
comms
/
other
/
rxsocket
/
examples
/
echotcp.rexx
< prev
next >
Wrap
OS/2 REXX Batch file
|
1998-05-09
|
1KB
|
59 lines
/*
echo tcp client - Usage: echotcp <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: echotcp <host>"
exit
end
addr = resolve(host)
if addr=="-1" then do
say "echotcp: no host <" || host || ">"
exit
end
if ~getservbyname("SE","echo","tcp") then do
say "echotcp: echo tcp service not found"
exit
end
sin.ADDRFAMILY = "INET"
sin.ADDRADDR = addr
sin.ADDRPORT = SE.SERVPORT
sock = socket("INET","STREAM","IP")
if sock<0 then do
say "echotcp: no socket (" || errno() || ")"
exit
end
if connect(sock,"SIN")<0 then do
say "echotcp: connect error (" || errno() || ")"
exit
end
REQUEST = "echo service test"
res = send(sock,REQUEST,x2d(100))
if res~=length(REQUEST) then do
say "echotcp: send error (" || errno() || ")"
exit
end
len = recv(sock,"BUF",256,x2d(100))
if len<0 then do
say "echotcp: recv error (" || errno() || ")"
exit
end
say buf
call CloseSocket(sock)