Definition
server_socket_open(port)
Features
The robot controller creates a server socket and waits for the connection to the client. Returns the connected socket when the client is connected.
Parameters
|
Parameter Name |
Data Type |
Default Value |
Description |
|---|---|---|---|
|
port |
int |
- |
Port number to open |
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 = server_socket_open(20002)
# Opens the port 20002 and waits until the client connects.
# The connected socket is returned if the connection is successful.
# The data is read, written, and closed using the returned socket as shown below.
server_socket_write(sock, b"123abc") # Sends data to the client (b represents the byte type).
res, rx_data = server_socket_read(sock) # Receives the data from the client.
server_socket_close(sock) # Closes the connection to the client.