]> git.donarmstrong.com Git - qmk_firmware.git/blob - tool/mbed/mbed-sdk/libraries/net/lwip/Socket/Endpoint.h
Squashed 'tmk_core/' changes from 7967731..b9e0ea0
[qmk_firmware.git] / tool / mbed / mbed-sdk / libraries / net / lwip / Socket / Endpoint.h
1 /* Copyright (C) 2012 mbed.org, MIT License
2  *
3  * Permission is hereby granted, free of charge, to any person obtaining a copy of this software
4  * and associated documentation files (the "Software"), to deal in the Software without restriction,
5  * including without limitation the rights to use, copy, modify, merge, publish, distribute,
6  * sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is
7  * furnished to do so, subject to the following conditions:
8  *
9  * The above copyright notice and this permission notice shall be included in all copies or
10  * substantial portions of the Software.
11  *
12  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING
13  * BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
14  * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
15  * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
16  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
17  */
18 #ifndef ENDPOINT_H
19 #define ENDPOINT_H
20
21 class UDPSocket;
22
23 /**
24 IP Endpoint (address, port)
25 */
26 class Endpoint {
27     friend class UDPSocket;
28
29 public:
30     /** IP Endpoint (address, port)
31      */
32     Endpoint(void);
33     
34     ~Endpoint(void);
35     
36     /** Reset the address of this endpoint
37      */
38     void reset_address(void);
39     
40     /** Set the address of this endpoint
41     \param host The endpoint address (it can either be an IP Address or a hostname that will be resolved with DNS).
42     \param port The endpoint port
43     \return 0 on success, -1 on failure (when an hostname cannot be resolved by DNS).
44      */
45     int  set_address(const char* host, const int port);
46     
47     /** Get the IP address of this endpoint
48     \return The IP address of this endpoint.
49      */
50     char* get_address(void);
51     
52     /** Get the port of this endpoint
53     \return The port of this endpoint
54      */
55     int get_port(void);
56
57 protected:
58     char _ipAddress[17];
59     struct sockaddr_in _remoteHost;
60
61 };
62
63 #endif