+ tmp_dir = opendir(USER_TMP_DIR);
+ if (!tmp_dir) {
+ return -1;
+ }
+
+ while ((dirent = readdir(tmp_dir))) {
+ if (!strncmp(dirent->d_name, USER_SOCK_DIR_BASE,
+ strlen(USER_SOCK_DIR_BASE))) {
+
+ if (asprintf(&sock_name, USER_TMP_DIR "/%s/%u",
+ dirent->d_name, pid) < 0) {
+ goto close_tmp_dir;
+ }
+
+ result = ustcomm_connect_path(sock_name, app_fd);
+
+ free(sock_name);
+
+ if (result == 0) {
+ goto close_tmp_dir;
+ }
+ }
+ }
+
+close_tmp_dir:
+ closedir(tmp_dir);
+
+ return result;