Skip to main content
Skip table of contents

server_socket_open(port)

기능

로봇 제어기가 서버 소켓을 생성하고, client의 연결을 대기합니다. client가 연결되면, 연결된 소켓을 반환합니다.

인수

인수명자료형기본값설명

port

int

-

오픈 할 port 번호

리턴

설명

socket.socket instance

연결 성공

예외

예외설명

DR_Error (DR_ERROR_TYPE)

인수의 데이터형 오류 시

DR_Error (DR_ERROR_VALUE)

인수의 값이 유효하지 않을 시

DR_Error (DR_ERROR_RUNTIME)

연결 처리 중 socket.error 예외 발생

예제

PY
sock = server_socket_open(20002) 
# 20002 port를 열고 client가 접속해 올 때까지 대기합니다. 
# 정상적으로 연결된 경우, 연결된 소켓을 반환합니다. 
# 반환된 소켓(sock)을 이용하여 하기와 같이 데이터를 쓰고 읽고 닫습니다.

server_socket_write(sock, b"123abc") #client에 데이터 전송 (b는 byte형을 의미)
res, rx_data = server_socket_read(sock) #client로부터 데이터 수신

server_socket_close(sock)           # client와의 연결 닫기 
JavaScript errors detected

Please note, these errors can depend on your browser setup.

If this problem persists, please contact our support.