Sending Base64 Over Sockets.

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: Klaus, FourthWorld, heatherlaine, kevinmiller

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

Sending Base64 Over Sockets.

Post by Googie85 » Fri Nov 14, 2014 11:30 pm

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.
Last edited by Googie85 on Sat Nov 15, 2014 12:37 pm, edited 1 time in total.

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

Re: Sending Base64 Over Sockets.

Post by Googie85 » Sat Nov 15, 2014 8:49 am

Here is my code currently...
Attachments
Client.zip
Client
(1.36 KiB) Downloaded 57 times
Server.zip
Server
(1.43 KiB) Downloaded 55 times

newtronsols
Posts: 192
Joined: Tue Mar 11, 2014 12:57 pm

Re: Sending Base64 Over Sockets.

Post by newtronsols » Sat Nov 15, 2014 10:29 am

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

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

Re: Sending Base64 Over Sockets.

Post by Googie85 » Sat Nov 15, 2014 10:56 am

I don't understand...

Klaus
Posts: 11834
Joined: Sat Apr 08, 2006 8:41 am
Location: Germany
Contact:

Re: Sending Base64 Over Sockets.

Post by Klaus » Sat Nov 15, 2014 12:36 pm

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

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

Re: Sending Base64 Over Sockets.

Post by Googie85 » Sat Nov 15, 2014 12:45 pm

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.

Post Reply

Return to “Getting Started with LiveCode - Complete Beginners”