ip.h
1 /*************************************************************************/
2 /* ip.h */
3 /*************************************************************************/
4 /* This file is part of: */
5 /* GODOT ENGINE */
6 /* http://www.godotengine.org */
7 /*************************************************************************/
8 /* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
9 /* */
10 /* Permission is hereby granted, free of charge, to any person obtaining */
11 /* a copy of this software and associated documentation files (the */
12 /* "Software"), to deal in the Software without restriction, including */
13 /* without limitation the rights to use, copy, modify, merge, publish, */
14 /* distribute, sublicense, and/or sell copies of the Software, and to */
15 /* permit persons to whom the Software is furnished to do so, subject to */
16 /* the following conditions: */
17 /* */
18 /* The above copyright notice and this permission notice shall be */
19 /* included in all copies or substantial portions of the Software. */
20 /* */
21 /* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
22 /* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
23 /* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
24 /* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
25 /* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
26 /* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
27 /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
28 /*************************************************************************/
29 #ifndef IP_H
30 #define IP_H
31 
32 
33 #include "os/os.h"
34 #include "io/ip_address.h"
35 
36 struct _IP_ResolverPrivate;
37 
38 class IP : public Object {
39  OBJ_TYPE( IP, Object );
40  OBJ_CATEGORY("Networking");
41 public:
42 
43  enum ResolverStatus {
44 
45  RESOLVER_STATUS_NONE,
46  RESOLVER_STATUS_WAITING,
47  RESOLVER_STATUS_DONE,
48  RESOLVER_STATUS_ERROR,
49  };
50 
51  enum {
52  RESOLVER_MAX_QUERIES = 32,
53  RESOLVER_INVALID_ID=-1
54  };
55 
56 
57  typedef int ResolverID;
58 
59 
60 private:
61 
62  _IP_ResolverPrivate *resolver;
63 protected:
64 
65  static IP*singleton;
66  static void _bind_methods();
67 
68  virtual IP_Address _resolve_hostname(const String& p_hostname)=0;
69  Array _get_local_addresses() const;
70 
71  static IP* (*_create)();
72 public:
73 
74 
75 
76  IP_Address resolve_hostname(const String& p_hostname);
77  // async resolver hostname
78  ResolverID resolve_hostname_queue_item(const String& p_hostname);
79  ResolverStatus get_resolve_item_status(ResolverID p_id) const;
80  IP_Address get_resolve_item_address(ResolverID p_id) const;
81  virtual void get_local_addresses(List<IP_Address> *r_addresses) const=0;
82  void erase_resolve_item(ResolverID p_id);
83 
84  static IP* get_singleton();
85 
86  static IP* create();
87 
88  IP();
89  ~IP();
90 
91 
92 };
93 
94 #endif // IP_H
Definition: array.h:38
Definition: ip.cpp:39
Definition: ip.h:38
Definition: list.h:44
Definition: ip_address.h:34
Definition: ustring.h:64
Definition: object.h:317