Skip to main content
Skip table of contents

server_socket_write(sock, tx_data)

Features

This function transmits data to the client.

Parameters

Parameter NameData TypeDefault ValueDescription

sock

socket.socket

-

Socket instance returned from server_socket_open()

socket instance

tx_data

byte

-

Data to be transmitted

  • The data type must be a byte.
  • Refer to the example below.

Return

ValueDescription

0

Success

-1

The client is not connected.

-2

client is disconnected, or

socket.error occurred during a data transfer

Exception

ExceptionDescription

DR_Error (DR_ERROR_TYPE)

Parameter data type error occurred

Example

PY
sock = server_socket_open(20002)
 
server_socket_write(sock, b"1234abcd") # b means the byte type.
 
msg = "abcd"    # msg is a string variable.
server_socket_write(sock, msg.encode()) # encode() converts a string type to a byte type.
 
server_socket_close(sock)
JavaScript errors detected

Please note, these errors can depend on your browser setup.

If this problem persists, please contact our support.