Definition
client_socket_write(sock, tx_data)
Features
This function transmits data to the server.
Parameters
|
Parameter Name |
Data Type |
Default Value |
Description |
|---|---|---|---|
|
sock |
socket.socket |
- |
Socket instance returned from client_socket_open() |
|
tx_data |
byte |
- |
Data to be transmitted
|
Return
|
Value |
Description |
|---|---|
|
0 |
Success |
|
-1 |
The server is not connected. |
|
-2 |
Server is disconnected, or socket.error occurred during a data transfer |
Exception
|
Exception |
Description |
|---|---|
|
DR_Error (DR_ERROR_TYPE) |
Parameter data type error occurred |
Example
Python
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)