Keyboard firmwares for Atmel AVR and Cortex-M
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

Endpoint.h 2.1KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  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. class UDPSocket;
  21. /**
  22. IP Endpoint (address, port)
  23. */
  24. class Endpoint {
  25. friend class UDPSocket;
  26. public:
  27. /** IP Endpoint (address, port)
  28. */
  29. Endpoint(void);
  30. ~Endpoint(void);
  31. /** Reset the address of this endpoint
  32. */
  33. void reset_address(void);
  34. /** Set the address of this endpoint
  35. \param host The endpoint address (it can either be an IP Address or a hostname that will be resolved with DNS).
  36. \param port The endpoint port
  37. \return 0 on success, -1 on failure (when an hostname cannot be resolved by DNS).
  38. */
  39. int set_address(const char* host, const int port);
  40. /** Get the IP address of this endpoint
  41. \return The IP address of this endpoint.
  42. */
  43. char* get_address(void);
  44. /** Get the port of this endpoint
  45. \return The port of this endpoint
  46. */
  47. int get_port(void);
  48. protected:
  49. char _ipAddress[17];
  50. struct sockaddr_in _remoteHost;
  51. };
  52. #endif