Xbase++
Xbase++
Send Bytes on a Socket Connection
See more Socket/SSL/TLS Examples
Demonstrates how to send a mixture of binary (non-text) and text bytes on a socket connection.Chilkat Xbase++ Downloads
LOCAL nSuccess
LOCAL oSocket
LOCAL nSsl
LOCAL nMaxWaitMillisec
LOCAL nPort
LOCAL oBd
nSuccess := 0
// This example requires the Chilkat API to have been previously unlocked.
// See Global Unlock Sample for sample code.
oSocket := CreateObject("Chilkat.Socket")
// Connect to some host:port
nSsl := 0
nMaxWaitMillisec := 20000
nPort := 5555
nSuccess := oSocket:Connect("test.com", nPort, nSsl, nMaxWaitMillisec)
IF (nSuccess != 1)
? oSocket:LastErrorText
oSocket:destroy()
RETURN
ENDIF
// We wish to send a 0x00 byte followed by the us-ascii string "10800"
oBd := CreateObject("Chilkat.BinData")
oBd:AppendByte(0)
oBd:AppendString("10800", "utf-8")
// Send the entire contents of bd.
nSuccess := oSocket:SendBd(oBd, 0, 0)
IF (nSuccess != 1)
? oSocket:LastErrorText
oSocket:destroy()
oBd:destroy()
RETURN
ENDIF
oSocket:destroy()
oBd:destroy()