servers/actuators-text/main.cc

Go to the documentation of this file.
00001 /*
00002  * This file is part of openSDK.
00003  *
00004  * Copyright (C) 2006  openSDK team
00005  *
00006  * openSDK is free software; you can redistribute it and/or modify
00007  * it under the terms of the GNU General Public License as published by
00008  * the Free Software Foundation; either version 2 of the License, or
00009  * (at your option) any later version.
00010  *
00011  * openSDK is distributed in the hope that it will be useful,
00012  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00013  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
00014  * GNU General Public License for more details.
00015  *
00016  * You should have received a copy of the GNU General Public License
00017  * along with openSDK; if not, write to the Free Software
00018  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
00019  *
00020  *     $Id: main.cc,v 1.2 2006/03/16 17:39:27 nuno-lopes Exp $
00021  */
00022 
00023 #include <sys/types.h>
00024 #include <sys/socket.h>
00025 #include <sys/un.h>
00026 #include <stdio.h>
00027 #include <unistd.h>
00028 #include <string.h>
00029 #include <iostream>
00030 #include <Platform.h>
00031 
00032 using namespace std;
00033 #define CHECK_SYSCALL(val, msg) if ((val) == -1) { perror(msg); return 3; }
00034 
00035 
00036 int main(int argc, char *argv[])
00037 {
00038         int sock;
00039         CHECK_SYSCALL(sock = socket(AF_UNIX, SOCK_STREAM, 0), "socket() failed")
00040 
00041         struct sockaddr_un addr;
00042         addr.sun_family = AF_UNIX;
00043         strcpy(addr.sun_path, "../../tests/RobotDesign/MS/" ACTUATORS_SERVER_SOCKET);
00044 
00045         // sleep until connected
00046         while(connect(sock, (struct sockaddr*)&addr, sizeof(addr)) == -1)
00047                 sleep(1);
00048 
00049         cout << "connected! :)" << endl;
00050 
00051         close(sock);
00052         return 0;
00053 }

Generated on Sun Dec 2 23:04:29 2007 for openSDK by  doxygen 1.3.9.1