How To Handle A Long Socket Transfer

Got a LiveCode personal license? Are you a beginner, hobbyist or educator that's new to LiveCode? This forum is the place to go for help getting started. Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller

Post Reply
Googie85
Posts: 227
Joined: Tue Aug 05, 2014 10:07 am

How To Handle A Long Socket Transfer

Post by Googie85 » Mon Nov 17, 2014 9:20 am

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.
Last edited by Googie85 on Mon Nov 17, 2014 1:28 pm, edited 1 time in total.

Googie85
Posts: 227
Joined: Tue Aug 05, 2014 10:07 am

Re: How To Handle A Long Socket Transfer

Post by Googie85 » Mon Nov 17, 2014 1:07 pm

*Edited, I posted the wrong code...

zaxos
Posts: 222
Joined: Thu May 23, 2013 11:15 pm

Re: How To Handle A Long Socket Transfer

Post by zaxos » Mon Nov 17, 2014 8:15 pm

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
Knowledge is meant to be shared.

Post Reply