3.7.0 3.6.0 3.5.0 3.4.0 3.3.0 3.2.2 3.2.1 3.2.0 Korean English Chinese Czech Dutch French German Hungarian Italian Japanese Polish Portuguese Spanish
3.7.0 3.6.0 3.5.0 3.4.0 3.3.0 3.2.2 3.2.1 3.2.0 Korean English Chinese Czech Dutch French German Hungarian Italian Japanese Polish Portuguese Spanish

client_socket_state()

Definition

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 Name

Data Type

Default Value

Description

sock

socket.socket

-

Socket instance returned from client_socket_open()

Return

Value

Description

1

Socket normal state

0

Socket abnormal state

Exception

Exception

Description

DR_Error (DR_ERROR_TYPE)

Parameter data type error occurred

Example

Python
sock = client_socket_open("192.168.137.200", 20002)

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

client_socket_close(sock)

Example 2

Python
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)

Keyword

client / client_ / socket / client_socket / client_socket_