Page 1 of 1

How To Handle A Long Socket Transfer

Posted: Mon Nov 17, 2014 9:20 am
by Googie85
I am trying to send a long file over sockets. At the end of each chunk of the file my script sends, it returns a message "DoneSending". I am trying to find a way to make it send the return message at the end of the transfer when all chunks are finished sending. Is there an expression I could add to the write socket command that could achieve this?

Code: Select all

write WAVSEND to socket FILESERVER with message "DoneSending"
Im trying to get the DoneSending message at the end of the transfer...

Many Thanks,

Matthew.

Re: How To Handle A Long Socket Transfer

Posted: Mon Nov 17, 2014 1:07 pm
by Googie85
*Edited, I posted the wrong code...

Re: How To Handle A Long Socket Transfer

Posted: Mon Nov 17, 2014 8:15 pm
by zaxos
Not sure if i understood your questing well but her's a possible answer:

Code: Select all

write "chunk" & chunk1 & {end} into socket theSocket with message "DoneSending"
write "chunk" & chunk2 & {end} into socket theSocket with message "DoneSending"
write "chunk" & chunk3 & {end} into socket theSocket with message "DoneSending"
write "chunk" & chunk4 & {end} into socket theSocket with message "DoneSending"
write "theEnd" into socket theSocket with message "DoneSending"

Code: Select all

on DoneSending theSocket , theMSG
if theMSG contains "theEnd" then
write "Finished!" to socket theSocket
else
replace "{end}" with "" in theMSG
put theMSG after theWholeMSG
read from socket theSocket untill "{end}"
end if
end DoneSending