DongEun Koak / NetworkSocketAPI

Dependencies:   DnsQuery

Dependents:   HelloWizFi250Interface

Fork of NetworkSocketAPI by NetworkSocketAPI

SocketInterface.cpp

Committer:
Christopher Haster
Date:
2016-02-18
Branch:
api-changes
Revision:
23:1e86d9fb3d86
Child:
28:163fbe3263f4

File content as of revision 23:1e86d9fb3d86:

/* SocketInterface Base Class
 * Copyright (c) 2015 ARM Limited
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

#include "SocketInterface.h"
#include <stdlib.h>
#include <string.h>

#define IP_SIZE 16

SocketInterface::SocketInterface()
  : _ip_address(0)
  , _port(0) {
}

SocketInterface::~SocketInterface() {
    if (_ip_address) free(_ip_address);
}

void SocketInterface::setIPAddress(const char *ip) {
    _ip_address = (char*)malloc(IP_SIZE);
    strcpy(_ip_address, ip);
}

void SocketInterface::setPort(uint16_t port) {
    _port = port;
}

const char *SocketInterface::getIPAddress() {
    return _ip_address;
}

uint16_t SocketInterface::getPort() {
    return _port;
}