Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Fork of MTS-Socket by
Endpoint.cpp
- Committer:
- Mike Fiore
- Date:
- 2014-05-20
- Revision:
- 3:d0a1fdbd02ce
- Parent:
- 1:096f484f3ae6
File content as of revision 3:d0a1fdbd02ce:
#include "mbed.h" #include "Socket.h" #include "Endpoint.h" #include "MTSLog.h" #include <cstring> using std::memset; using namespace mts; Endpoint::Endpoint() { reset_address(); } Endpoint::~Endpoint() { } void Endpoint::reset_address(void) { _ipAddress[0] = '\0'; _port = 0; } int Endpoint::set_address(const char* host, const int port) { int length = strlen(host) + 1; // size of host including terminating character if (length > sizeof(_ipAddress)) { logError("could not set address because the hostname is too long"); return -1; } else { strncpy((char*) _ipAddress, host, length); _ipAddress[length] = '\0'; _port = port; } return 0; } char* Endpoint::get_address() { return _ipAddress; } int Endpoint::get_port() { return _port; }