cdlSocket.h
Go to the documentation of this file.
00001 /*
00002  *   Katana Native Interface - A C++ interface to the robot arm Katana.
00003  *   Copyright (C) 2005 Neuronics AG
00004  *   Check out the AUTHORS file for detailed contact information.
00005  *
00006  *   This program 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  *   This program 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 this program; if not, write to the Free Software
00018  *   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00019  */
00020 
00021 
00022 
00023 #ifndef _CDLSOCKET_H_
00024 #define _CDLSOCKET_H_
00025 
00026 #include "common/dllexport.h"
00027 #include "common/Timer.h"
00028 
00029 #include "KNI/cdlBase.h"
00030 #include "KNI/cdlCOMExceptions.h"
00031 
00032 //-------------------------------------------------------//
00033 #ifdef WIN32
00034 //-------------------------------------------------------//
00035         #include <windows.h>
00036         #include <winsock.h>
00037         #include <stdio.h>
00038 //-------------------------------------------------------//
00039 #else //LINUX
00040 //-------------------------------------------------------//
00041         #include <sys/types.h>
00042         #include <sys/socket.h>
00043         #include <netinet/in.h>
00044         #include <arpa/inet.h>
00045         #include <cerrno>
00046         #include <unistd.h>
00047         //<tfromm date="22.05.2009">
00048         //#include <string>
00049         #include <cstring>
00050         #include <cstdlib>
00051         //</tfromm>
00052 //-------------------------------------------------------//
00053 #endif //WIN32 else LINUX
00054 //-------------------------------------------------------//
00055 
00056 
00057 //--------------------------------------------------------------------------//
00065 class DLLDIR CCdlSocket : public CCdlBase {
00066 private:
00068 
00069         char* _ipAddr;
00071         int _port;
00073         int _len;
00074 //-------------------------------------------------------//
00075 #ifdef WIN32
00076 //-------------------------------------------------------//
00077         //Windows specific socket handles:
00078         SOCKET _socketfd;
00079         SOCKADDR_IN _socketAddr;
00080 
00081 //-------------------------------------------------------//
00082 #else //LINUX
00083 //-------------------------------------------------------//
00084         //Unix specific socket handles:
00086         int _socketfd;
00088         struct sockaddr_in _socketAddr;
00089 //-------------------------------------------------------//
00090 #endif //WIN32 else LINUX
00091 //-------------------------------------------------------//
00092 
00093 protected:
00094 
00097         static char digit(const int _val) {
00098                 return (char)((int)'0' + _val);
00099         }
00100 
00101 public:
00109         CCdlSocket(char* adress, int port);
00110 
00113         virtual ~CCdlSocket();
00114 
00117         virtual int  send(const void* _buf, int _size);
00118 
00121         virtual int  recv(void* _buf, int _size);
00122 
00125         virtual int  disconnect();
00126 };
00127 
00128 
00129 #endif //_CDLSOCKET_H_
00130 


kni
Author(s): Martin Günther
autogenerated on Mon Aug 14 2017 02:44:12