udpsocket.hh
Go to the documentation of this file.
/*
** udpsocket.hh
** Login : Julien Lemoine <speedblue@happycoders.org>
** Started on Sun Mar 2 00:53:36 2003 Julien Lemoine
** $Id: udpsocket.hh,v 1.2 2004/06/01 21:30:54 speedblue Exp $
**
** Copyright (C) 2003,2004 Julien Lemoine
** This program is free software; you can redistribute it and/or modify
** it under the terms of the GNU Lesser General Public License as published by
** the Free Software Foundation; either version 2 of the License, or
** (at your option) any later version.
**
** This program is distributed in the hope that it will be useful,
** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
** GNU Lesser General Public License for more details.
**
** You should have received a copy of the GNU Lesser General Public License
** along with this program; if not, write to the Free Software
** Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#ifndef UDP_SOCKET_HH_
# define UDP_SOCKET_HH_
#include "netsocket.hh"
namespace Network
{
class UdpSocket : public NetSocket
{
public:
UdpSocket(SOCKET_VERSION version = V4) :
NetSocket(UDP, version)
{}
UdpSocket(PROTO_KIND pkind, SOCKET_VERSION version = V4) :
NetSocket(UDP, pkind, version)
{}
virtual ~UdpSocket()
{
close();
}
public:
void connect(const std::string& hostname, int port);
void connect(int port);
void close();
protected:
std::string _read_line_bin(int socket, int& port,
std::string& host,
unsigned int pkg_size);
std::string _read_line_bin(int socket, unsigned int size);
};
}
#endif /* !UDP_SOCKET_HH_ */
Network::NetSocket
This class represent an abstract socket connection (udp | tcp server | tcp client)
Definition netsocket.hh:34
Network::UdpSocket
This class represent a udp connection (client and server)
Definition udpsocket.hh:33
Network::UdpSocket::_read_line_bin
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
Network::UdpSocket::connect
void connect(const std::string &hostname, int port)
Connect as an UDP client.
Definition udpsocket.cc:27
Network::UdpSocket::UdpSocket
UdpSocket(PROTO_KIND pkind, SOCKET_VERSION version=V4)
Definition udpsocket.hh:38
Network::UdpSocket::~UdpSocket
virtual ~UdpSocket()
Definition udpsocket.hh:42
Network::UdpSocket::UdpSocket
UdpSocket(SOCKET_VERSION version=V4)
Definition udpsocket.hh:35
Network::UdpSocket::close
void close()
Close the connection.
Definition udpsocket.cc:39
Network
Network namespace represent all networks connection.
Definition localsocket.cc:33
Network::V4
@ V4
Definition socket.hh:87
Network::UDP
@ UDP
Definition socket.hh:81
Network::SOCKET_VERSION
enum Network::e_version SOCKET_VERSION
Network::PROTO_KIND
enum Network::e_pkind PROTO_KIND
netsocket.hh