pdcomm_opcua_server_create
함수
메모리 내 OPC UA 서버를 만들고 바인딩합니다.
int32_t pdcomm_opcua_server_create(pdcomm_opcua_bytes bind_address, const pdcomm_opcua_server_options *options, pdcomm_opcua_handle *out)서버는 표준 주소 공간(address space)을 소유합니다. 여기에는 Server 객체, 인덱스 2에 urn:pdcomm:opcua:nodes가 있는 네임스페이스 배열, 표준 타입이 들어 있습니다. 서버는 Discovery, Session, View, Attribute, Method, Subscription, MonitoredItem 서비스를 메모리에서 제공합니다. 외부 공급자, 이벤트, 이력(history), PubSub(Part 14)는 없습니다.
memset(&options, 0, sizeof(options));
options.struct_size = (uint32_t)sizeof(options);
options.version = 1;
status = pdcomm_opcua_server_options_init(&options);
if (status != PDCOMM_OPCUA_OK) { print_error("options", status); goto done; }
options.endpoint.data = (const uint8_t *)argv[2];
options.endpoint.size = strlen(argv[2]);
options.certificate_der.data = certificate;
options.certificate_der.size = certificate_size;
options.private_key_pem.data = key;
options.private_key_pem.size = key_size;
options.trusted_client_der.data = trust;
options.trusted_client_der.size = trust_size;
bind.data = (const uint8_t *)argv[1];
bind.size = strlen(argv[1]);
status = pdcomm_opcua_server_create(bind, &options, &server);
example_wipe(key, key_size); // The SDK copied the identity.
(examples/opcua/opcua_server.c에서 발췌)
매개변수
| 이름 | 설명 |
|---|---|
bind_address | 수신 대기할 숫자 소켓 주소입니다(예: 127.0.0.1:4840, 0.0.0.0:0, [::1]:4840). 포트 0은 빈 포트를 고릅니다. pdcomm_opcua_server_local_address()를 참고합니다. |
options | 초기화한 옵션입니다. 호출 중에만 복사됩니다. |
out | 서버 핸들을 받습니다. |
반환값
성공하면 #PDCOMM_OPCUA_OK를 반환합니다. 주소, 옵션, 플래그, 한도, 인증서 또는 키가 유효하지 않거나, #PDCOMM_OPCUA_ALLOW_NONE 없이 ID 정보가 빠졌으면 #PDCOMM_OPCUA_INVALID_INPUT을 반환합니다. 바인딩이 실패하거나, 엔드포인트 URL이 유효하지 않거나, 인증서가 애플리케이션 URI와 맞지 않으면 #PDCOMM_OPCUA_RUNTIME_ERROR를 반환합니다. 그 밖에 #PDCOMM_OPCUA_LIMIT를 반환할 수 있고, opcua-server 라이선스가 없으면 #PDCOMM_OPCUA_LICENSE_REQUIRED를 반환합니다(아무것도 바인딩하지 않습니다).
참고
- 서버는 pdcomm_opcua_server_poll() 중에만 클라이언트에 서비스를 제공합니다.