Avnet / WNCInterface

Dependencies:   WncControllerK64F

Dependents:   WNCProximityMqtt Pubnub_ATT_IoT_SK_WNC_sync BluemixDemo BluemixQS ... more

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers WncEndpoint.h Source File

WncEndpoint.h

00001 /* =====================================================================
00002    Copyright © 2016, Avnet (R)
00003 
00004    Contributors:
00005      * James M Flynn, www.em.avnet.com 
00006  
00007    Licensed under the Apache License, Version 2.0 (the "License"); 
00008    you may not use this file except in compliance with the License.
00009    You may obtain a copy of the License at
00010 
00011     http://www.apache.org/licenses/LICENSE-2.0
00012 
00013    Unless required by applicable law or agreed to in writing, 
00014    software distributed under the License is distributed on an 
00015    "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 
00016    either express or implied. See the License for the specific 
00017    language governing permissions and limitations under the License.
00018 
00019     @file          WNCInterface.cpp
00020     @version       1.0
00021     @date          Sept 2016
00022 
00023 ======================================================================== */
00024 
00025 
00026 #ifndef ENDPOINT_H
00027 #define ENDPOINT_H
00028 
00029 #include "WncSocket.h"
00030 
00031 struct EndPointAddr {
00032   char IP[16];
00033   unsigned int port;
00034   };
00035 
00036 class WncUDPSocket;
00037 
00038 class WncEndpoint {
00039     friend class WncUDPSocket;
00040 
00041 public:
00042     WncEndpoint(void);
00043     ~WncEndpoint(void);
00044     
00045     /** Reset the address of the endpoint by clearning the internal endpoint IP address
00046     \param none
00047     \return none.
00048      */
00049     void reset_address(void);
00050 
00051     /** Set the address of the endpoint
00052     \param host The endpoint address (it can either be an IP Address or a hostname that will be resolved with DNS).
00053     \param port The endpoint port
00054     \return 0 on success, -1 on failure (when an hostname cannot be resolved by DNS).
00055      */
00056     int  set_address(const char* host, const int port);
00057 
00058     /** Get the IP address of the endpoint
00059     \return The IP address of the endpoint.
00060      */
00061     char* get_address(void); 
00062 
00063     /** Get the port of the endpoint
00064     \return The port of the endpoint
00065      */
00066     int get_port(void);
00067 
00068 private:
00069     EndPointAddr _epAddr;
00070 };
00071   
00072 #endif