Page 1 of 1

Sending Base64 Over Sockets.

Posted: Fri Nov 14, 2014 11:30 pm
by Googie85
I am trying to send a file over sockets (base64 encoded) and am getting differing results at the other end of the transfer. I have an image of the client and server to give you an idea about the problem I am having.

Server:

Image

Client:

Image

I basically want to get the same result as the server in the client window. The code to send is as follows:

Code: Select all

command PROT
   put the URL "binfile:c:\windows\temp\test.jpg" into BASEVAR
   put the base64encode of BASEVAR into BASE64
   global IPADDRESS
   write BASE64 to socket IPADDRESS
end PROT

Any ideas would be great!

Many Thanks,

Matthew.

Re: Sending Base64 Over Sockets.

Posted: Sat Nov 15, 2014 8:49 am
by Googie85
Here is my code currently...

Re: Sending Base64 Over Sockets.

Posted: Sat Nov 15, 2014 10:29 am
by newtronsols
i just downloaded a file from the web and access on Windows via:

file:///C:/Users/david/Downloads/246225287-Wanless-Report.pdf

you are using backslash

Re: Sending Base64 Over Sockets.

Posted: Sat Nov 15, 2014 10:56 am
by Googie85
I don't understand...

Re: Sending Base64 Over Sockets.

Posted: Sat Nov 15, 2014 12:36 pm
by Klaus
Hi Google85,

you are reading the image as TEXT file, use BINFILE instead!
And always use the SLASH as a pathdelimiter INSIDE of Livecode!

You only need to supply platform specific (well, Windows only :-) )
pathdelimiter when using SHELL command with pathnames!

Code: Select all

command PROT
   put URL("BINFILE:C/Windows/temp/test.jpg") into BASEVAR
   put base64encode(BASEVAR) into BASE64
   global IPADDRESS
   write BASE64 to socket IPADDRESS
end PROT
Best

Klaus

Re: Sending Base64 Over Sockets.

Posted: Sat Nov 15, 2014 12:45 pm
by Googie85
I figured that out myself, but instead of sending a JPEG (which looks garbled) I tried a .WAV file and it plays but it is really distorted and scratchy. Is my data being corrupted over the transfer?

Many Thanks,

Matt.