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_open()

Definition

client_socket_open(ip, port)

Features

This function creates a socket and attempts to connect it to a server (ip, port).

It returns the connected socket when the client is connected.

Parameters

Parameter Name

Data Type

Default Value

Description

ip

str

-

Server IP address: (E.g.) “192.168.137.200”

port

int

-

Server Port number (e.g.) 20002

Return

Value

Description

socket.socket instance

Successful connection

Exception

Exception

Description

DR_Error (DR_ERROR_TYPE)

Parameter data type error occurred

DR_Error (DR_ERROR_VALUE)

Parameter value is invalid

DR_Error (DR_ERROR_RUNTIME)

socket.error occurred during a connection

Example

Python
sock = client_socket_open("192.168.137.200", 20002)
# An indefinite connection is attempted to the server (ip="192.168.137.200", port=20002). 
# The connected socket is returned if the connection is successful. 
# The data is read, written, and closed using the returned socket as shown below. 
 
client_socket_write(sock, b"123abc")   # Sends data to the server (b represents the byte type).   
res, rx_data = client_socket_read(sock) # Receives the data from the server. 
client_socket_close(sock)             # Closes the connection to the server. 

Keyword

client / client_ / socket / client_socket / client_socket_