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