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