Command group Flag affected Reversible Execute on client Platform(s)
External commands YES NO NO All


TCPSend (socket,bufferReturns sent-byte-count


Note: The flag is set according to whether Omnis was able to make a call to this external command.

This Web command is multi-threaded, allowing another thread to execute in the multi-threaded server while it runs. Note that the same socket cannot safely be used concurrently by more than one thread.

Socket is a long integer field containing the socket number of a connected socket.

Buffer is a character or binary field containing the data to send on the socket. If you pass a character field, then TCPSend will convert the data to UTF-8, and then send the UTF-8.

TCPSend returns the number of bytes it sent to sent-byte-count, a long Integer field.

If the socket is in blocking mode, TCPSend always sends all of the data, unless an error occurs.

If the socket is in non-blocking mode, TCPSend sends as much data as it can without blocking.

If an error occurs, TCPSend returns a negative error code


If the connection is secure (see TCPConnect) then the send will always be blocking, even if the socket is marked as non-blocking.

Non-blocking sockets return an error code of -10035 if the socket cannot accept the data to send immediately. Some implementations of socket libraries may have limits on the number of bytes you can send at one time. Consult the documentation for your installed sockets libraries. You may have to send a message in multiple chunks in order to send a very long message. Always check sent-byte-count to determine how much of the buffer has actually been sent; if the value is less than the buffer size, you need to call TCPSend again, to send the rest of the buffer.

It does not make sense to send a character field on a non-blocking socket, because the sent-byte-count corresponds to the sent UTF-8 bytes.


; Connect to the server IP address iHostName on port iPort and send
; the message iMessage
Calculate iHostName as ''
Calculate iPort as 6000
Calculate lMessage as 'Hello remote application'
TCPConnect (iHostName,iPort) Returns iSocket
If iSocket>0
  ; connected
  TCPSend (iSocket,lMessage) Returns lByteCount
End If