MOOS 0.2375
|
00001 00002 // 00003 // MOOS - Mission Oriented Operating Suite 00004 // 00005 // A suit of Applications and Libraries for Mobile Robotics Research 00006 // Copyright (C) 2001-2005 Massachusetts Institute of Technology and 00007 // Oxford University. 00008 // 00009 // This software was written by Paul Newman at MIT 2001-2002 and Oxford 00010 // University 2003-2005. email: pnewman@robots.ox.ac.uk. 00011 // 00012 // This file is part of a MOOS CORE Component. 00013 // 00014 // This program is free software; you can redistribute it and/or 00015 // modify it under the terms of the GNU General Public License as 00016 // published by the Free Software Foundation; either version 2 of the 00017 // License, or (at your option) any later version. 00018 // 00019 // This program is distributed in the hope that it will be useful, 00020 // but WITHOUT ANY WARRANTY; without even the implied warranty of 00021 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00022 // General Public License for more details. 00023 // 00024 // You should have received a copy of the GNU General Public License 00025 // along with this program; if not, write to the Free Software 00026 // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 00027 // 02111-1307, USA. 00028 // 00029 // The XPC classes in MOOS are modified versions of the source provided 00030 // in "Making UNIX and Windows NT Talk" by Mark Nadelson and Thomas Haga 00031 // 00033 00034 00035 #ifndef _XPCUdpSocket 00036 #define _XPCUdpSocket 00037 00038 #include "XPCSocket.h" 00039 #include <map> 00040 00041 00042 class XPCUdpSocket : public XPCSocket 00043 { 00044 public: 00045 00046 // Constructor. Used to create a new udp socket - it will receive on _iPort 00047 XPCUdpSocket(long int _iPort) ; 00048 00049 // Sends a message to a specified host on a specified port. The number of bytes sent is returned 00050 int iSendMessageTo(void *_vMessage, int _iMessageSize,long int nPort,const std::string & sHost); 00051 00052 //send a telegram to all local network nodes on specified ports 00053 int iBroadCastMessage(void *_vMessage, int _iMessageSize,long int nPort); 00054 00055 // Receives a UDP message 00056 int iRecieveMessage(void *_vMessage, int _iMessageSize, int _iOption = 0); 00057 00058 // Binds the socket to listen on a port number 00059 void vBindSocket(); 00060 00061 // allows a read with a timeout to prevent from blocking indefinitely 00062 //int iReadMessageWithTimeOut(void *_vMessage, int _iMessageSize, double dfTimeOut,int _iOption=0); 00063 00064 protected: 00065 bool GetAddress(long int nPort,const std::string & sHost,sockaddr_in & Address); 00066 00067 std::map< std::pair< long int , std::string >, sockaddr_in > m_KnownAdresses ; 00068 00069 00070 }; 00071 00072 #endif