Breadcrumbs

server_socket_write()

Definition

server_socket_write(sock, tx_data)

Features

This function transmits data to the client.

Parameters

Parameter Name

Data Type

Default Value

Description

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

Value

Description

0

Success

-1

The client is not connected.

-2

client 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 = 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)