libassa 3.5.1
Loading...
Searching...
No Matches
UDPSocket.h
Go to the documentation of this file.
1// -*- c++ -*-
2//------------------------------------------------------------------------------
3// UDPSocket.h
4//------------------------------------------------------------------------------
5// Copyright (c) 1999,2006 by Vladislav Grinchenko
6//
7// This library is free software; you can redistribute it and/or
8// modify it under the terms of the GNU Library General Public
9// License as published by the Free Software Foundation; either
10// version 2 of the License, or (at your option) any later version.
11//------------------------------------------------------------------------------
12// Created: 03/22/99
13//------------------------------------------------------------------------------
14#ifndef UDP_SOCKET_H
15#define UDP_SOCKET_H
16
17#include "assa/Socket.h"
18
19namespace ASSA {
20
28class UDPSocket : public Socket {
29public:
32 {
33 trace("UDPSocket::UDPSocket()");
34 }
35
40 {
41 trace("UDPSocket::UDPSocket(fd)");
42 m_fd = fd_;
43 }
44
46 virtual ~UDPSocket ()
47 {
48 trace("UDPSocket::~UDPSocket");
49 }
50
58 bool open (const int domain_);
59
63 bool close ();
64
71 bool bind (const Address& my_address_);
72
74 handler_t getHandler() const { return m_fd; }
75
77 const int getDomain() const { return m_type; }
78
79protected:
81 void setHandler(const int fd_) { m_fd = fd_; }
82
84 void setDomain(const int type_) { m_type = type_; }
85};
86
87} // end namespace ASSA
88
89#endif // UDP_SOCKET_H
90
91
#define trace(s)
trace() is used to trace function call chain in C++ program.
Definition Logger.h:429
Abstraction of socket data type.
A wrapper class to provide AutoPtr with reference semantics.
Definition AutoPtr.h:32
int m_type
Socket domain type.
Definition Socket.h:488
handler_t m_fd
File descriptor.
Definition Socket.h:485
const int getDomain() const
Get socket domain type.
Definition UDPSocket.h:77
void setHandler(const int fd_)
Set file descriptor.
Definition UDPSocket.h:81
handler_t getHandler() const
Get socket file descriptor.
Definition UDPSocket.h:74
UDPSocket()
Default constructor.
Definition UDPSocket.h:31
UDPSocket(const handler_t fd_)
Constructor.
Definition UDPSocket.h:39
virtual ~UDPSocket()
Destructor will close connection.
Definition UDPSocket.h:46
bool open(const int domain_)
Create socket.
Definition UDPSocket.cpp:22
bool bind(const Address &my_address_)
Server in UDP client-server scenario has to bind socket to its local well-known port.
Definition UDPSocket.cpp:52
void setDomain(const int type_)
Set socket domain type.
Definition UDPSocket.h:84
bool close()
Close socket connection.
Definition UDPSocket.cpp:39