Sample code for 30+ languages & platforms
Xbase++

Send Encoded Bytes over a Socket

See more Socket/SSL/TLS Examples

Demonstrates Socket.SendBytesENC, which decodes text using a named encoding (such as base64) and sends the resulting binary bytes.

Background. The ENC methods move raw binary data to and from printable text using a named encoding such as base64 or hex, which is convenient for logging or for handling binary data as strings.

Chilkat Xbase++ Downloads

Xbase++
LOCAL nSuccess
LOCAL oSocket
LOCAL nBTls
LOCAL nMaxWaitMs

nSuccess := 0

oSocket := CreateObject("Chilkat.Socket")

//  Connect to the server using TLS.
nBTls := 1
nMaxWaitMs := 5000
nSuccess := oSocket:Connect("example.com", 5000, nBTls, nMaxWaitMs)
IF (nSuccess == 0)
    ? oSocket:LastErrorText
    oSocket:destroy()
    RETURN
ENDIF

//  Decode the text using the named encoding, then send the resulting binary bytes.  Here the base64
//  text "SGVsbG8=" decodes to the bytes for "Hello".
nSuccess := oSocket:SendBytesENC("SGVsbG8=", "base64")
IF (nSuccess == 0)
    ? oSocket:LastErrorText
    oSocket:destroy()
    RETURN
ENDIF

? "Bytes sent."

oSocket:destroy()