libktorrent  2.2.0
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:59
net::SocketDevice
Definition: socketdevice.h:50
net::Poll
Definition: poll.h:64