Archived Forum Post

Index of archived forum posts

Question:

Transferring file using sockets

Apr 10 '17 at 18:56

I want to transfer files (applications and pictures) using sockets. I'm using visualfoxpro and I'm really at my first steps with sockets. I tried to get the file content with filetostring function and the send it with oSocket.sendstring() but what I received is not what I send. How can I get throught that ?

Thank you Alessio


Answer

To avoid problems with binary files. I frequently convert files to base64 or HexBinary with StrConvert(lcString, 13) and at the other end bring it back with StrConvert(lcString, 14).

base64 is 13 and back with 14
hexBinary is 15 and back to 16

Hope that helps. Tracy


Answer

Thank you Tracy it was exactly as you said :)


Answer

Here's a better example: https://www.example-code.com/foxpro/socket_transfer_file.asp

:)