libktorrent
2.2.0
src
utp
utpsocket.h
1
/***************************************************************************
2
* Copyright (C) 2009 by Joris Guisson *
3
* joris.guisson@gmail.com *
4
* *
5
* This program is free software; you can redistribute it and/or modify *
6
* it under the terms of the GNU General Public License as published by *
7
* the Free Software Foundation; either version 2 of the License, or *
8
* (at your option) any later version. *
9
* *
10
* This program is distributed in the hope that it will be useful, *
11
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
12
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
13
* GNU General Public License for more details. *
14
* *
15
* You should have received a copy of the GNU General Public License *
16
* along with this program; if not, write to the *
17
* Free Software Foundation, Inc., *
18
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. *
19
***************************************************************************/
20
21
#ifndef UTP_UTPSOCKET_H
22
#define UTP_UTPSOCKET_H
23
24
#include <ktorrent_export.h>
25
#include <util/constants.h>
26
#include <net/socketdevice.h>
27
#include <utp/connection.h>
28
29
namespace
utp
30
{
31
35
class
KTORRENT_EXPORT
UTPSocket
:
public
net::SocketDevice
36
{
37
public
:
38
UTPSocket
();
39
UTPSocket
(Connection::WPtr conn);
40
~
UTPSocket
()
override
;
41
42
int
fd()
const override
;
43
bool
ok()
const override
;
44
int
send(
const
bt::Uint8* buf,
int
len)
override
;
45
int
recv(bt::Uint8* buf,
int
max_len)
override
;
46
void
close()
override
;
47
void
setBlocking(
bool
on)
override
;
48
bt::Uint32 bytesAvailable()
const override
;
49
bool
setTOS(
unsigned
char
type_of_service)
override
;
50
bool
connectTo(
const
net::Address
& addr)
override
;
51
bool
connectSuccesFull
()
override
;
52
const
net::Address
& getPeerName()
const override
;
53
net::Address
getSockName()
const override
;
54
void
reset
()
override
;
55
void
prepare
(
net::Poll
* p, net::Poll::Mode mode)
override
;
56
bool
ready
(
const
net::Poll
* p, net::Poll::Mode mode)
const override
;
57
58
private
:
59
Connection::WPtr conn;
60
bool
blocking;
61
mutable
bool
polled_for_reading;
62
mutable
bool
polled_for_writing;
63
};
64
}
65
66
#endif // UTPSOCKET_H
net::Address
Definition:
address.h:41
net::SocketDevice
Definition:
socketdevice.h:32
utp::UTPSocket::connectSuccesFull
bool connectSuccesFull() override
See if a connectTo was succesfull in non blocking mode.
utp::UTPSocket::ready
bool ready(const net::Poll *p, net::Poll::Mode mode) const override
Check if the socket is ready according to the poll.
utp::UTPSocket
Definition:
utpsocket.h:36
net::Poll
Definition:
poll.h:64
utp::UTPSocket::reset
void reset() override
reset the socket (i.e. close it and create a new one)
utp::UTPSocket::prepare
void prepare(net::Poll *p, net::Poll::Mode mode) override
Prepare for polling.
Generated by
1.8.20