- /* configure the socket */
- if (fd >= 0) {
- fcntl(fd, F_SETFD, FD_CLOEXEC);
- fcntl(fd, F_SETFL, O_NONBLOCK);
- }
- return fd;
-}
-
-/**********************************************************************************/
-
-int afb_api_ws_add_client(const char *path, struct afb_apiset *apiset, int strong)
-{
- struct api_ws *apiws;
- struct afb_stub_ws *stubws;
-
- /* create the ws client api */
- apiws = api_ws_make(path);
- if (apiws == NULL)
- goto error;
-
- /* connect to the service */
- apiws->fd = api_ws_socket(apiws->path, 0);
- if (apiws->fd < 0) {
- ERROR("can't connect to ws service %s", apiws->path);
- goto error2;
- }
-
- stubws = afb_stub_ws_create_client(apiws->fd, apiws->api, apiset);
- if (!stubws) {
- ERROR("can't setup client ws service to %s", apiws->path);
- goto error3;
- }
- if (afb_stub_ws_client_add(stubws, apiset) < 0) {
- ERROR("can't add the client to the apiset for service %s", apiws->path);
- goto error4;
- }
- free(apiws);
- return 0;
-error4:
- afb_stub_ws_unref(stubws);
-error3:
- close(apiws->fd);
-error2:
- free(apiws);