Skip to main content
Skip table of contents

client_socket_write(sock, tx_data)

Features

This function transmits data to the server.

Parameters

Parameter NameData TypeDefault ValueDescription

sock

socket.socket

-

Socket instance returned from client_socket_open()

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 server is not connected.

-2

Server 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 = client_socket_open("192.168.137.200", 20002)
 
client_socket_write(sock, b"1234abcd") # b means the byte type.
 
msg = "abcd" # msg is a string variable.
client_socket_write(sock, msg.encode()) # encode() converts a string type to a byte type. 
 
client_socket_close(sock)
JavaScript errors detected

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

If this problem persists, please contact our support.