home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
OS/2 Shareware BBS: 35 Internet
/
35-Internet.zip
/
bircv02b.zip
/
dcc_get.cmd
< prev
next >
Wrap
OS/2 REXX Batch file
|
1999-03-12
|
2KB
|
116 lines
/* BiRC: DCC get.... */
/* LONG IP: (FirstPart*16777216) + (SecondPart * 65536) + (ThirdPart * 256) + (FourthPart) */
call RxFuncAdd 'SysLoadFuncs','RexxUtil','SysLoadFuncs'
call SysLoadFuncs
call RxFuncAdd 'SockLoadFuncs','RxSock','SockLoadFuncs'
parse arg nick file longip port filesize
LastPart = (LongIP // 256)%1
ThirdPart = (LongIP / 256 // 256)%1
SecondPart = (LongIP / 65536 // 256)%1
FirstPart = (LongIP / 16777216 // 256)%1
ip=firstpart'.'secondpart'.'thirdpart'.'lastpart
call SockLoadFuncs 'q'
'@echo off'
say 'DCC: Responding to request from' nick' ['ip']'
socket = SockSocket("AF_INET","SOCK_STREAM",0)
if (socket = -1) then
do
say "Error on SockSocket:" errno
exit
end
signal on halt
server.!family = "AF_INET"
server.!port = port
server.!addr = ip
rc = SockConnect(socket,"server.!")
if (rc = -1) then
do
say "Error on SockConnect:" errno
exit
end
say 'Connected!'
'if exist 'file' del 'file
say 'Size of file: 'filesize
bytesreceived=0
finished='false'
call stream file, 'c', 'open write'
do until (finished='true')
rc = SockRecv(socket, "data",512)
if (rc = -1) then
do
say "Error on SockRecv:" errno
exit
end
call charout file, data
bytesreceived=bytesreceived+length(data)
call charout ,bytesreceived' bytes received.'||d2c(13)
prelim=''
/* if length(d2c(bytesreceived)<4) then
do i=1 to length(bytesreceived)
prelim=prelim||'0'
end */
/* call SockSend socket, prelim||d2c(bytesreceived) */
byte4 = (bytesreceived // 256)%1
byte3 = (bytesreceived / 256 // 256)%1
byte2 = (bytesreceived / 65536 // 256)%1
byte1 = (bytesreceived / 16777216 // 256)%1
call SockSend socket, d2c(byte1)||d2c(byte2)||d2c(byte3)||d2c(byte4)
if (bytesreceived=filesize/* || length(data)=0*/) then finished='true'
end /* Main do loop */
call stream file, 'c', 'close'
halt()
exit
/* Exit procedure */
halt:
rc = SockSoClose(socket)
if (rc = -1) then
do
say "Error on SockSoClose:" errno
exit
end
exit
/*
byte4 = (bytesreceived // 256)%1
byte3 = (bytesreceived / 256 // 256)%1
byte2 = (bytesreceived / 65536 // 256)%1
byte1 = (bytesreceived / 16777216 // 256)%1
*/