I use an idea that Kistech came up with for a project of his that he was generous enough to share with the me. It involves using IanM's matrix plugins and his bank commands to read bytes from a file and sending those bytes to the receiving end.
This is pretty much the basics behind the server side (sender) of the code that I use to send files:
array index to top updatingFiles()
while array index valid(updatingFiles()) = 1
if mn client connected(0,updatingFiles().playerNum) = 1
if updatingFiles().filesize - updatingFiles().pos > 0
done = 0
memsize = 31999
if updatingFiles().pos + memsize > updatingFiles().filesize
memsize = updatingFiles().filesize-updatingFiles().pos-1
done = 1
endif
`make memblock from bank 1,updatingFiles().bankNum,updatingFiles().pos,memsize
`memsize = get memblock size(1)
mn add byte sendPacket, 1 `1 = file download operation
mn add string sendPacket,updatingFiles().directory,0,1
mn add string sendPacket,updatingFiles().filename,0,1
mn add double int sendPacket,updatingFiles().filesize
mn add double int sendPacket,updatingFiles().pos
mn add int sendPacket,memsize
for i = 0 to memsize
mn add byte sendPacket, bank byte(updatingFiles().bankNum,updatingFiles().pos+i)
next i
`mn add memblock sendPacket,get memblock ptr(1),memsize,1
mn send tcp 0,sendPacket,updatingFiles().playerNum,0,0
`delete memblock 1
inc updatingFiles().pos,32000
if done = 1 `or updatingFiles().pos >= updatingFiles().filesize
array delete element updatingFiles()
endif
else
array delete element updatingFiles()
endif
else
array delete element updatingFiles()
endif
next array index updatingFiles()
endwhile
and the client side (receiving):
` Check for new TCP messages
iTCPPackets = mn Recv TCP(INST_CONNECT,RecvPacket,0)
` If there is a new TCP message
if iTCPPackets > 0
Operation = mn get byte(RecvPacket)
if Operation = 1
directory$ = mn get string(RecvPacket,0,1)
fileName$ = mn get string(RecvPacket,0,1)
filesize = mn get double int(RecvPacket)
pos = mn get double int(RecvPacket)
memsize = mn get int(RecvPacket)
if firstReceive = 1
if bank exist(updatingFile(0).banknum)=1 then delete bank updatingFile(0).banknum
if path exist(maindir$+"\"+directory$) = 0
make directory maindir$+"\"+directory$
endif
updatingFile(0).banknum = find free bank()
make bank updatingFile(0).banknum,filesize
downloadDone = 0
firstReceive = 0
endif
updatingFile(0).directory = directory$
updatingFile(0).filename = filename$
updatingFile(0).filesize = filesize
updatingFile(0).pos = pos
for i = 0 to memsize
write bank byte updatingFile(0).banknum, updatingFile(0).pos+i ,mn get byte (RecvPacket)
next i
inc updatingFile(0).pos,32000
if updatingFile(0).pos >= filesize
downloadDone = 1
if filename$ = "manifest.txt"
gotManifest = 1
manifestRead = 0
endif
updatingFile(0).directory = ""
updatingFile(0).filename = ""
updatingFile(0).filesize = 0
updatingFile(0).pos = 0
tempdir$ = ""
if len(directory$)>0 then tempdir$ = directory$ + "\"
if file exist(directory$ + filename$) = 1 then delete file directory$ + filename$
make file from bank directory$ + filename$,updatingFile(0).banknum
delete bank updatingFile(0).banknum
endif
endif
endif
endif
"What I have shown you is reality. What you remember, that is the illusion."