Skip to main content
Skip table of contents

(2.11.2_temp-en_US) client_socket_state(sock)

Features

This function returns the socket connection status.To know the connection status with the server, check the return value of client_socket_read or client_socket_write (see Example 2).

Parameters

Parameter NameData TypeDefault ValueDescription

sock

socket.socket

-

Socket instance returned

from client_socket_open()

Return

ValueDescription

1

Socket normal state

0

Socket abnormal state

Exception

ExceptionDescription

DR_Error (DR_ERROR_TYPE)

Parameter data type error occurred

Example

PY
sock = client_socket_open("192.168.137.200", 20002)

state = client_socket_state(sock) # Reads the socket state.

client_socket_close(sock)

Example 2

PY
sock = client_socket_open("192.168.137.200", 20002)
res, rx_data =client_socket_read(sock)
tp_log("[RX] res={0}, rx_data ={1}".format(res, rx_data)) 
if (res < 0):
   tp_log("[RX] server disconnect") #When the server connection is disconnected 
   client_socket_close(sock)             
   exit()
 
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.