/** * FreeRDP: A Remote Desktop Protocol Client * Unix Domain Socket Utils * * Copyright 2012 Vic Lee * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #ifdef HAVE_CONFIG_H #include "config.h" #endif #include #include #include #include #include #include #include #ifndef _WIN32 #include #include #include #include #include #include #include #include #endif int freerdp_uds_connect(const char* path) { #ifndef _WIN32 int status; int sockfd; struct sockaddr_un addr; sockfd = socket(AF_UNIX, SOCK_STREAM, 0); if (sockfd == -1) { perror("socket"); return -1; } addr.sun_family = AF_UNIX; strncpy(addr.sun_path, path, sizeof(addr.sun_path)); status = connect(sockfd, (struct sockaddr *) &addr, sizeof(addr)); if (status < 0) { perror("connect"); close(sockfd); return -1; } return sockfd; #else /* ifndef _WIN32 */ return -1; #endif }