PowerBuilder
PowerBuilder
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 PowerBuilder Downloads
integer li_rc
integer li_Success
oleobject loo_Socket
integer li_Ssl
integer li_MaxWaitMillisec
integer li_Port
oleobject loo_Bd
li_Success = 0
// This example requires the Chilkat API to have been previously unlocked.
// See Global Unlock Sample for sample code.
loo_Socket = create oleobject
li_rc = loo_Socket.ConnectToNewObject("Chilkat.Socket")
if li_rc < 0 then
destroy loo_Socket
MessageBox("Error","Connecting to COM object failed")
return
end if
// Connect to some host:port
li_Ssl = 0
li_MaxWaitMillisec = 20000
li_Port = 5555
li_Success = loo_Socket.Connect("test.com",li_Port,li_Ssl,li_MaxWaitMillisec)
if li_Success <> 1 then
Write-Debug loo_Socket.LastErrorText
destroy loo_Socket
return
end if
// We wish to send a 0x00 byte followed by the us-ascii string "10800"
loo_Bd = create oleobject
li_rc = loo_Bd.ConnectToNewObject("Chilkat.BinData")
loo_Bd.AppendByte(0)
loo_Bd.AppendString("10800","utf-8")
// Send the entire contents of bd.
li_Success = loo_Socket.SendBd(loo_Bd,0,0)
if li_Success <> 1 then
Write-Debug loo_Socket.LastErrorText
destroy loo_Socket
destroy loo_Bd
return
end if
destroy loo_Socket
destroy loo_Bd