<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/> <title>KatanaNativeInterface: include/KNI/cdlSocket.h Source File</title> <link href="tabs.css" rel="stylesheet" type="text/css"/> <link href="navtree.css" rel="stylesheet" type="text/css"/> <script type="text/javascript" src="jquery.js"></script> <script type="text/javascript" src="navtree.js"></script> <script type="text/javascript" src="resize.js"></script> <script type="text/javascript"> $(document).ready(initResizable); </script> <link href="doxygen.css" rel="stylesheet" type="text/css"/> </head> <body> <!-- Generated by Doxygen 1.7.3 --> <div id="top"> <div id="titlearea"> <table cellspacing="0" cellpadding="0"> <tbody> <tr style="height: 56px;"> <td style="padding-left: 0.5em;"> <div id="projectname">KatanaNativeInterface <span id="projectnumber">$VERSION$</span></div> </td> </tr> </tbody> </table> </div> <div id="navrow1" class="tabs"> <ul class="tablist"> <li><a href="index.html"><span>Main Page</span></a></li> <li><a href="modules.html"><span>Modules</span></a></li> <li><a href="namespaces.html"><span>Namespaces</span></a></li> <li><a href="annotated.html"><span>Classes</span></a></li> <li class="current"><a href="files.html"><span>Files</span></a></li> <li><a href="dirs.html"><span>Directories</span></a></li> </ul> </div> <div id="navrow2" class="tabs2"> <ul class="tablist"> <li><a href="files.html"><span>File List</span></a></li> <li><a href="globals.html"><span>File Members</span></a></li> </ul> </div> </div> <div id="side-nav" class="ui-resizable side-nav-resizable"> <div id="nav-tree"> <div id="nav-tree-contents"> </div> </div> <div id="splitbar" style="-moz-user-select:none;" class="ui-resizable-handle"> </div> </div> <script type="text/javascript"> initNavTree('cdlSocket_8h.html',''); </script> <div id="doc-content"> <div class="header"> <div class="headertitle"> <h1>cdlSocket.h</h1> </div> </div> <div class="contents"> <a href="cdlSocket_8h.html">Go to the documentation of this file.</a><div class="fragment"><pre class="fragment"><a name="l00001"></a>00001 <span class="comment">/*</span> <a name="l00002"></a>00002 <span class="comment"> * Katana Native Interface - A C++ interface to the robot arm Katana.</span> <a name="l00003"></a>00003 <span class="comment"> * Copyright (C) 2005 Neuronics AG</span> <a name="l00004"></a>00004 <span class="comment"> * Check out the AUTHORS file for detailed contact information.</span> <a name="l00005"></a>00005 <span class="comment"> *</span> <a name="l00006"></a>00006 <span class="comment"> * This program is free software; you can redistribute it and/or modify</span> <a name="l00007"></a>00007 <span class="comment"> * it under the terms of the GNU General Public License as published by</span> <a name="l00008"></a>00008 <span class="comment"> * the Free Software Foundation; either version 2 of the License, or</span> <a name="l00009"></a>00009 <span class="comment"> * (at your option) any later version.</span> <a name="l00010"></a>00010 <span class="comment"> *</span> <a name="l00011"></a>00011 <span class="comment"> * This program is distributed in the hope that it will be useful,</span> <a name="l00012"></a>00012 <span class="comment"> * but WITHOUT ANY WARRANTY; without even the implied warranty of</span> <a name="l00013"></a>00013 <span class="comment"> * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the</span> <a name="l00014"></a>00014 <span class="comment"> * GNU General Public License for more details.</span> <a name="l00015"></a>00015 <span class="comment"> *</span> <a name="l00016"></a>00016 <span class="comment"> * You should have received a copy of the GNU General Public License</span> <a name="l00017"></a>00017 <span class="comment"> * along with this program; if not, write to the Free Software</span> <a name="l00018"></a>00018 <span class="comment"> * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA</span> <a name="l00019"></a>00019 <span class="comment"> */</span> <a name="l00020"></a>00020 <a name="l00021"></a>00021 <a name="l00022"></a>00022 <a name="l00023"></a>00023 <span class="preprocessor">#ifndef _CDLSOCKET_H_</span> <a name="l00024"></a>00024 <span class="preprocessor"></span><span class="preprocessor">#define _CDLSOCKET_H_</span> <a name="l00025"></a>00025 <span class="preprocessor"></span> <a name="l00026"></a>00026 <span class="preprocessor">#include "common/dllexport.h"</span> <a name="l00027"></a>00027 <span class="preprocessor">#include "common/Timer.h"</span> <a name="l00028"></a>00028 <a name="l00029"></a>00029 <span class="preprocessor">#include "KNI/cdlBase.h"</span> <a name="l00030"></a>00030 <span class="preprocessor">#include "KNI/cdlCOMExceptions.h"</span> <a name="l00031"></a>00031 <a name="l00032"></a>00032 <span class="comment">//-------------------------------------------------------//</span> <a name="l00033"></a>00033 <span class="preprocessor">#ifdef WIN32</span> <a name="l00034"></a>00034 <span class="preprocessor"></span><span class="comment">//-------------------------------------------------------//</span> <a name="l00035"></a>00035 <span class="preprocessor"> #include <windows.h></span> <a name="l00036"></a>00036 <span class="preprocessor"> #include <winsock.h></span> <a name="l00037"></a>00037 <span class="preprocessor"> #include <stdio.h></span> <a name="l00038"></a>00038 <span class="comment">//-------------------------------------------------------//</span> <a name="l00039"></a>00039 <span class="preprocessor">#else //LINUX</span> <a name="l00040"></a>00040 <span class="preprocessor"></span><span class="comment">//-------------------------------------------------------//</span> <a name="l00041"></a>00041 <span class="preprocessor"> #include <sys/types.h></span> <a name="l00042"></a>00042 <span class="preprocessor"> #include <sys/socket.h></span> <a name="l00043"></a>00043 <span class="preprocessor"> #include <netinet/in.h></span> <a name="l00044"></a>00044 <span class="preprocessor"> #include <arpa/inet.h></span> <a name="l00045"></a>00045 <span class="preprocessor"> #include <cerrno></span> <a name="l00046"></a>00046 <span class="preprocessor"> #include <unistd.h></span> <a name="l00047"></a>00047 <span class="preprocessor"> #include <string></span> <a name="l00048"></a>00048 <span class="comment">//-------------------------------------------------------//</span> <a name="l00049"></a>00049 <span class="preprocessor">#endif //WIN32 else LINUX</span> <a name="l00050"></a>00050 <span class="preprocessor"></span><span class="comment">//-------------------------------------------------------//</span> <a name="l00051"></a>00051 <a name="l00052"></a>00052 <a name="l00053"></a>00053 <span class="comment">//--------------------------------------------------------------------------//</span> <a name="l00061"></a><a class="code" href="classCCdlSocket.html">00061</a> <span class="comment"></span><span class="keyword">class </span><a class="code" href="dllexport_8h.html#af6e7daabccc187ef1005a8e9a68ecce4">DLLDIR</a> <a class="code" href="classCCdlSocket.html" title="Encapsulates the socket communication device.">CCdlSocket</a> : <span class="keyword">public</span> <a class="code" href="classCCdlBase.html" title="Abstract base class for devices.">CCdlBase</a> { <a name="l00062"></a>00062 <span class="keyword">private</span>: <a name="l00064"></a>00064 <a name="l00065"></a><a class="code" href="classCCdlSocket.html#ad26f28af38c2be23e9578e4d9523cc2c">00065</a> <span class="keywordtype">char</span>* <a class="code" href="classCCdlSocket.html#ad26f28af38c2be23e9578e4d9523cc2c" title="IP Address of the Robot or simulation environment.">_ipAddr</a>; <a name="l00067"></a><a class="code" href="classCCdlSocket.html#adb631218ba3425c088d1c772d8e60f91">00067</a> <span class="keywordtype">int</span> <a class="code" href="classCCdlSocket.html#adb631218ba3425c088d1c772d8e60f91" title="Port number of the KNI communication socket.">_port</a>; <a name="l00069"></a><a class="code" href="classCCdlSocket.html#a1ee5023fd6083dbf4f48447777df5006">00069</a> <span class="keywordtype">int</span> <a class="code" href="classCCdlSocket.html#a1ee5023fd6083dbf4f48447777df5006" title="Length of the message.">_len</a>; <a name="l00070"></a>00070 <span class="comment">//-------------------------------------------------------//</span> <a name="l00071"></a>00071 <span class="preprocessor">#ifdef WIN32</span> <a name="l00072"></a>00072 <span class="preprocessor"></span><span class="comment">//-------------------------------------------------------//</span> <a name="l00073"></a>00073 <span class="comment">//Windows specific socket handles:</span> <a name="l00074"></a>00074 SOCKET _socketfd; <a name="l00075"></a>00075 SOCKADDR_IN _socketAddr; <a name="l00076"></a>00076 <a name="l00077"></a>00077 <span class="comment">//-------------------------------------------------------//</span> <a name="l00078"></a>00078 <span class="preprocessor">#else //LINUX</span> <a name="l00079"></a>00079 <span class="preprocessor"></span><span class="comment">//-------------------------------------------------------//</span> <a name="l00080"></a>00080 <span class="comment">//Unix specific socket handles:</span> <a name="l00082"></a><a class="code" href="classCCdlSocket.html#a57e5f24038d8e41665f2789e01dadc3e">00082</a> <span class="comment"></span> <span class="keywordtype">int</span> <a class="code" href="classCCdlSocket.html#a57e5f24038d8e41665f2789e01dadc3e" title="File handler for the socket.">_socketfd</a>; <a name="l00084"></a><a class="code" href="classCCdlSocket.html#a05af853473345176ec84b128d26a022f">00084</a> <span class="keyword">struct </span>sockaddr_in _socketAddr; <a name="l00085"></a>00085 <span class="comment">//-------------------------------------------------------//</span> <a name="l00086"></a>00086 <span class="preprocessor">#endif //WIN32 else LINUX</span> <a name="l00087"></a>00087 <span class="preprocessor"></span><span class="comment">//-------------------------------------------------------//</span> <a name="l00088"></a>00088 <a name="l00089"></a>00089 <span class="keyword">protected</span>: <a name="l00090"></a>00090 <a name="l00093"></a><a class="code" href="classCCdlSocket.html#affc2cb0b2c9315151309ba95622e7a3c">00093</a> <span class="keyword">static</span> <span class="keywordtype">char</span> <a class="code" href="classCCdlSocket.html#affc2cb0b2c9315151309ba95622e7a3c" title="Converts an integer to a char.">digit</a>(<span class="keyword">const</span> <span class="keywordtype">int</span> _val) { <a name="l00094"></a>00094 <span class="keywordflow">return</span> (<span class="keywordtype">char</span>)((int)<span class="charliteral">'0'</span> + _val); <a name="l00095"></a>00095 } <a name="l00096"></a>00096 <a name="l00097"></a>00097 <span class="keyword">public</span>: <a name="l00105"></a>00105 <a class="code" href="classCCdlSocket.html" title="Encapsulates the socket communication device.">CCdlSocket</a>(<span class="keywordtype">char</span>* adress, <span class="keywordtype">int</span> port); <a name="l00106"></a>00106 <a name="l00109"></a>00109 <span class="keyword">virtual</span> ~<a class="code" href="classCCdlSocket.html" title="Encapsulates the socket communication device.">CCdlSocket</a>(); <a name="l00110"></a>00110 <a name="l00113"></a>00113 <span class="keyword">virtual</span> <span class="keywordtype">int</span> <a class="code" href="classCCdlBase.html#aba5536b5780002dfd20884b79d38f172" title="Pure function to send data.">send</a>(<span class="keyword">const</span> <span class="keywordtype">void</span>* _buf, <span class="keywordtype">int</span> _size); <a name="l00114"></a>00114 <a name="l00117"></a>00117 <span class="keyword">virtual</span> <span class="keywordtype">int</span> <a class="code" href="classCCdlBase.html#a206a79ca60593b62676f2ef3a8b157a1" title="Pure function to receive data.">recv</a>(<span class="keywordtype">void</span>* _buf, <span class="keywordtype">int</span> _size); <a name="l00118"></a>00118 <a name="l00121"></a>00121 <span class="keyword">virtual</span> <span class="keywordtype">int</span> disconnect(); <a name="l00122"></a>00122 }; <a name="l00123"></a>00123 <a name="l00124"></a>00124 <a name="l00125"></a>00125 <span class="preprocessor">#endif //_CDLSOCKET_H_</span> <a name="l00126"></a>00126 <span class="preprocessor"></span> </pre></div></div> </div> <div id="nav-path" class="navpath"> <ul> <li class="navelem"><a class="el" href="cdlSocket_8h.html">cdlSocket.h</a> </li> <li class="footer">Generated on Tue Feb 8 2011 for KatanaNativeInterface by  <a href="http://www.doxygen.org/index.html"> <img class="footer" src="doxygen.png" alt="doxygen"/></a> 1.7.3 </li> </ul> </div> </body> </html>