00001 /* 00002 ** udpsocket.hh 00003 ** Login : Julien Lemoine <speedblue@happycoders.org> 00004 ** Started on Sun Mar 2 00:53:36 2003 Julien Lemoine 00005 ** $Id: udpsocket.hh,v 1.2 2004/06/01 21:30:54 speedblue Exp $ 00006 ** 00007 ** Copyright (C) 2003,2004 Julien Lemoine 00008 ** This program is free software; you can redistribute it and/or modify 00009 ** it under the terms of the GNU Lesser General Public License as published by 00010 ** the Free Software Foundation; either version 2 of the License, or 00011 ** (at your option) any later version. 00012 ** 00013 ** This program is distributed in the hope that it will be useful, 00014 ** but WITHOUT ANY WARRANTY; without even the implied warranty of 00015 ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00016 ** GNU Lesser General Public License for more details. 00017 ** 00018 ** You should have received a copy of the GNU Lesser General Public License 00019 ** along with this program; if not, write to the Free Software 00020 ** Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 00021 */ 00022 00023 #ifndef UDP_SOCKET_HH_ 00024 # define UDP_SOCKET_HH_ 00025 00026 #include "netsocket.hh" 00027 00028 namespace Network 00029 { 00032 class UdpSocket : public NetSocket 00033 { 00034 public: 00035 UdpSocket(SOCKET_VERSION version = V4) : 00036 NetSocket(UDP, version) 00037 {} 00038 UdpSocket(PROTO_KIND pkind, SOCKET_VERSION version = V4) : 00039 NetSocket(UDP, pkind, version) 00040 {} 00041 00042 virtual ~UdpSocket() 00043 { 00044 close(); 00045 } 00046 00047 public: 00049 00088 void connect(const std::string& hostname, int port); 00090 00137 void connect(int port); 00139 void close(); 00140 protected: 00147 std::string _read_line_bin(int socket, int& port, 00148 std::string& host, 00149 unsigned int pkg_size); 00153 std::string _read_line_bin(int socket, unsigned int size); 00154 }; 00155 } 00156 00157 #endif /* !UDP_SOCKET_HH_ */