libsocket  1.5
udpsocket.hh
Go to the documentation of this file.
1 /*
2 ** udpsocket.hh
3 ** Login : Julien Lemoine <speedblue@happycoders.org>
4 ** Started on Sun Mar 2 00:53:36 2003 Julien Lemoine
5 ** $Id: udpsocket.hh,v 1.2 2004/06/01 21:30:54 speedblue Exp $
6 **
7 ** Copyright (C) 2003,2004 Julien Lemoine
8 ** This program is free software; you can redistribute it and/or modify
9 ** it under the terms of the GNU Lesser General Public License as published by
10 ** the Free Software Foundation; either version 2 of the License, or
11 ** (at your option) any later version.
12 **
13 ** This program is distributed in the hope that it will be useful,
14 ** but WITHOUT ANY WARRANTY; without even the implied warranty of
15 ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 ** GNU Lesser General Public License for more details.
17 **
18 ** You should have received a copy of the GNU Lesser General Public License
19 ** along with this program; if not, write to the Free Software
20 ** Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21 */
22 
23 #ifndef UDP_SOCKET_HH_
24 # define UDP_SOCKET_HH_
25 
26 #include "netsocket.hh"
27 
28 namespace Network
29 {
32  class UdpSocket : public NetSocket
33  {
34  public:
36  NetSocket(UDP, version)
37  {}
38  UdpSocket(PROTO_KIND pkind, SOCKET_VERSION version = V4) :
39  NetSocket(UDP, pkind, version)
40  {}
41 
42  virtual ~UdpSocket()
43  {
44  close();
45  }
46 
47  public:
49 
88  void connect(const std::string& hostname, int port);
90 
137  void connect(int port);
139  void close();
140  protected:
147  std::string _read_line_bin(int socket, int& port,
148  std::string& host,
149  unsigned int pkg_size);
153  std::string _read_line_bin(int socket, unsigned int size);
154  };
155 }
156 
157 #endif /* !UDP_SOCKET_HH_ */