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
28namespace Network
29{
32 class UdpSocket : public NetSocket
33 {
34 public:
36 NetSocket(UDP, version)
37 {}
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_ */
This class represent an abstract socket connection (udp | tcp server | tcp client)
Definition netsocket.hh:34
This class represent a udp connection (client and server)
Definition udpsocket.hh:33
std::string _read_line_bin(int socket, int &port, std::string &host, unsigned int pkg_size)
Get a line from socket and store client hostname and port in port and host variable (when used with b...
Definition udpsocket.cc:101
void connect(const std::string &hostname, int port)
Connect as an UDP client.
Definition udpsocket.cc:27
UdpSocket(PROTO_KIND pkind, SOCKET_VERSION version=V4)
Definition udpsocket.hh:38
virtual ~UdpSocket()
Definition udpsocket.hh:42
UdpSocket(SOCKET_VERSION version=V4)
Definition udpsocket.hh:35
void close()
Close the connection.
Definition udpsocket.cc:39
Network namespace represent all networks connection.
@ UDP
Definition socket.hh:81
enum Network::e_version SOCKET_VERSION
enum Network::e_pkind PROTO_KIND