Panda3D
Loading...
Searching...
No Matches
bioPtr.h
Go to the documentation of this file.
1/**
2 * PANDA 3D SOFTWARE
3 * Copyright (c) Carnegie Mellon University. All rights reserved.
4 *
5 * All use of this software is subject to the terms of the revised BSD
6 * license. You should have received a copy of this license along
7 * with this source code in a file named "LICENSE."
8 *
9 * @file bioPtr.h
10 * @author drose
11 * @date 2002-10-15
12 */
13
14#ifndef BIOPTR_H
15#define BIOPTR_H
16
17#include "pandabase.h"
18
19// This module is not compiled if OpenSSL is not available.
20#ifdef HAVE_OPENSSL
21
22#include "referenceCount.h"
23
24#ifdef _WIN32
25#include <winsock2.h>
26#include <ws2tcpip.h>
27#else
28#include <sys/socket.h>
29#include <netinet/in.h>
30#endif
31
32typedef struct bio_st BIO;
33
34class URLSpec;
35
36/**
37 * A wrapper around an OpenSSL BIO object to make a reference-counting pointer
38 * to it. It appears that the OpenSSL library already uses reference counts
39 * on these things internally, but the interface doesn't appear to be public;
40 * so we might as well wrap the whole thing at the high level.
41 */
42class EXPCL_PANDA_DOWNLOADER BioPtr : public ReferenceCount {
43public:
44 INLINE BioPtr(BIO *bio);
45 BioPtr(const URLSpec &url);
46 virtual ~BioPtr();
47
48 void set_nbio(bool nbio);
49 bool connect();
50
51 bool should_retry() const;
52
53 INLINE BIO &operator *() const;
54 INLINE BIO *operator -> () const;
55 INLINE operator BIO * () const;
56
57 INLINE void set_bio(BIO *bio);
58 INLINE BIO *get_bio() const;
59
60 INLINE const std::string &get_server_name() const;
61 INLINE int get_port() const;
62
63private:
64 BIO *_bio;
65 std::string _server_name;
66 int _port;
67 struct sockaddr_storage _addr;
68 socklen_t _addrlen;
69 bool _connecting;
70};
71
72#include "bioPtr.I"
73
74#endif // HAVE_OPENSSL
75
76
77#endif
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
A base class for all things that want to be reference-counted.
A container for a URL, e.g.
Definition urlSpec.h:28
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.