libassa
3.5.1
Main Page
Namespaces
Classes
Files
File List
File Members
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Friends
Macros
assa
UDPSocket.cpp
Go to the documentation of this file.
1
// -*- c++ -*-
2
//------------------------------------------------------------------------------
3
// UDPSocket.C
4
//------------------------------------------------------------------------------
5
// Copyright (c) 2000 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
//------------------------------------------------------------------------------
13
// Created: 03/22/99
14
//------------------------------------------------------------------------------
15
16
#include "
assa/UDPSocket.h
"
17
18
using namespace
ASSA;
19
20
bool
21
UDPSocket::
22
open
(
const
int
domain_)
23
{
24
trace
(
"UDPSocket::open"
);
25
26
m_type
= domain_;
27
m_fd
= ::socket (
m_type
, SOCK_DGRAM, 0);
28
29
if
(
m_fd
< 0) {
30
setstate
(
Socket::failbit
);
31
return
false
;
32
}
33
clear
();
34
return
true
;
35
}
36
37
bool
38
UDPSocket::
39
close
()
40
{
41
trace
(
"UDPSocket::close()"
);
42
if
(
m_fd
>= 0 ) {
43
::close
(
m_fd
);
44
setstate
(
Socket::failbit
);
45
m_fd
= -1;
46
}
47
return
true
;
48
}
49
50
bool
51
UDPSocket::
52
bind
(
const
Address
& my_address_)
53
{
54
trace
(
"UDPSocket::bind"
);
55
56
int
ret =
::bind
(
m_fd
, (
SA
*) my_address_.
getAddress
(),
57
my_address_.
getLength
());
58
if
(ret < 0) {
59
setstate
(
Socket::failbit
);
60
return
false
;
61
}
62
return
true
;
63
}
64
65
66
Generated on Tue Jun 19 2012 07:41:56 for libassa by
1.8.1.1