DataFlex
DataFlex
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 DataFlex Downloads
Use ChilkatAx-win32.pkg
Procedure Test
Boolean iSuccess
Handle hoSocket
Boolean iSsl
Integer iMaxWaitMillisec
Integer iPort
Variant vBd
Handle hoBd
String sTemp1
Move False To iSuccess
// This example requires the Chilkat API to have been previously unlocked.
// See Global Unlock Sample for sample code.
Get Create (RefClass(cComChilkatSocket)) To hoSocket
If (Not(IsComObjectCreated(hoSocket))) Begin
Send CreateComObject of hoSocket
End
// Connect to some host:port
Move False To iSsl
Move 20000 To iMaxWaitMillisec
Move 5555 To iPort
Get ComConnect Of hoSocket "test.com" iPort iSsl iMaxWaitMillisec To iSuccess
If (iSuccess <> True) Begin
Get ComLastErrorText Of hoSocket To sTemp1
Showln sTemp1
Procedure_Return
End
// We wish to send a 0x00 byte followed by the us-ascii string "10800"
Get Create (RefClass(cComChilkatBinData)) To hoBd
If (Not(IsComObjectCreated(hoBd))) Begin
Send CreateComObject of hoBd
End
Get ComAppendByte Of hoBd 0 To iSuccess
Get ComAppendString Of hoBd "10800" "utf-8" To iSuccess
// Send the entire contents of bd.
Get pvComObject of hoBd to vBd
Get ComSendBd Of hoSocket vBd 0 0 To iSuccess
If (iSuccess <> True) Begin
Get ComLastErrorText Of hoSocket To sTemp1
Showln sTemp1
Procedure_Return
End
End_Procedure