TcpWriteUTF


TcpWriteUTF connection, data$

This command writes 16 bit unicode characters to a specified TCP socket connection. This is a good function for sending UTF-8 string records. The TcpReadUTF$(n) command should be used to receive a strings sent by a TcpWriteUTF.

Strings are encoded in a slightly modified form of UTF-8. This form is identical to standard UTF-8, except:

- Only the one-, two-, and three-byte encodings are used.

- Characters in the range U+10000 thru U+10ffff are encoded as a surrogate pair, each of which is represented as a three-byte encoded value. The character U+0000 is encoded in two-byte form.

After a TcpReadUTF$(n) it is important to check if the read succeeded. All internet connections are subject to interruption at any time so check the TcpGetError$(n) after each TCP command you execute. TcpGetError$(n) will return an empty string if the read succeeded.

You can use the TcpGetSize(n) function to check how many bytes are available to be read.



TcpWriteUTF 1, data$

err$ = TcpGetError$(1)
if err$ <> "" then Print "Err: "; err$
if TcpGetState(1) <> 1 then Print "Connection Lost"




TcpOpen


TcpClose


TcpGetState()


TcpGetError$()


TCPGetAddr$()


TcpGetSize()


TcpRead


TcpReadln


TcpReadUTF


TcpWrite


TcpWriteln







Become a Patron