Skip to content

Raw Send and Receive

Qriist edited this page Sep 16, 2026 · 1 revision

RawSend and RawReceive operate at the protocol level, below HTTP. Use them for direct TCP data exchange where you need to control the byte stream yourself.

Setup

CONNECT_ONLY is required. It tells libcurl to establish the connection without performing a full HTTP transfer:

curl.SetOpt("URL", "127.0.0.1:12345")
curl.SetOpt("CONNECT_ONLY", 1)
curl.Sync()
; connection is now established, ready for raw I/O

Sending

RawSend transmits a single chunk of data. Accepts all common AHKv2 types:

curl.RawSend("fingers crossed")

msg := { status: "ok", seq: 42 }
curl.RawSend(msg)

buf := Buffer(1024, 0)
curl.RawSend(buf)

Receiving

RawReceive returns a Buffer. You are responsible for handling transmission delays. Loop until data arrives:

Loop {
    replyBuffer := curl.RawReceive()
} Until (replyBuffer.size != 0)

; Once data starts flowing, RawReceive gathers the full message before returning
text := StrGet(replyBuffer, "UTF-8")

General Flow

curl.SetOpt("URL", "127.0.0.1:12345")
curl.SetOpt("CONNECT_ONLY", 1)
curl.Sync()

curl.RawSend("hello")

Loop {
    replyBuffer := curl.RawReceive()
} Until (replyBuffer.size != 0)

MsgBox StrGet(replyBuffer, "UTF-8")

Note: Unlike Sync transfers, there is no built-in timeout or retry. The caller manages pacing, framing, and message boundaries.

Where to Go Next

Clone this wiki locally