Base class for IP Based Networking Libraries

Dependencies:   DnsQuery

Dependents:   TempTower BSDInterfaceTests HelloBSDInterface ESP8266InterfaceTests ... more

For a complete getting started guide see the wiki...

Network Socket API

The Network Socket API provides a common interface for using sockets on network devices. The API provides a simple class-based interface that should be familiar to users experienced with other socket APIs. Additionally, the API provides a simple interface for implementing network devices, making it easy to connect hardware agnostic programs to new devices.

Network Interfaces

The NetworkInterface provides an abstract class for network devices that support sockets. Devices should provide a DeviceInterface class that inherits this interface and adds implementation specific methods for using the device. A NetworkInterface must be provided to a Socket constructor to open a socket on the interface. Currently two subclasses are defined for common devices, EthernetInterface and WiFiInterface.

Sockets

The Socket class is used for managing network sockets. Once opened, the socket provides a pipe through which data can sent and recieved to a specific endpoint. The socket class can be instantiated as either a TCPSocket or a UDPSocket which defines the protocol used for the connection.

Committer:
Christopher Haster
Date:
Tue Apr 05 09:20:32 2016 -0500
Revision:
78:0914f9b9b24b
Parent:
76:bbe51641f405
Child:
79:43a7e8c0d6cc
Dragged over license from nsapi

Who changed what in which revision?

UserRevisionLine numberNew contents of line
Christopher Haster 78:0914f9b9b24b 1 /* Socket
Christopher Haster 78:0914f9b9b24b 2 * Copyright (c) 2015 ARM Limited
Christopher Haster 75:dea0cdb42241 3 *
Christopher Haster 78:0914f9b9b24b 4 * Licensed under the Apache License, Version 2.0 (the "License");
Christopher Haster 78:0914f9b9b24b 5 * you may not use this file except in compliance with the License.
Christopher Haster 78:0914f9b9b24b 6 * You may obtain a copy of the License at
Christopher Haster 75:dea0cdb42241 7 *
Christopher Haster 78:0914f9b9b24b 8 * http://www.apache.org/licenses/LICENSE-2.0
Christopher Haster 75:dea0cdb42241 9 *
Christopher Haster 78:0914f9b9b24b 10 * Unless required by applicable law or agreed to in writing, software
Christopher Haster 78:0914f9b9b24b 11 * distributed under the License is distributed on an "AS IS" BASIS,
Christopher Haster 78:0914f9b9b24b 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
Christopher Haster 78:0914f9b9b24b 13 * See the License for the specific language governing permissions and
Christopher Haster 78:0914f9b9b24b 14 * limitations under the License.
Christopher Haster 75:dea0cdb42241 15 */
Christopher Haster 78:0914f9b9b24b 16
Christopher Haster 76:bbe51641f405 17 #ifndef SOCKET_ADDRESS_H
Christopher Haster 76:bbe51641f405 18 #define SOCKET_ADDRESS_H
Christopher Haster 75:dea0cdb42241 19
Christopher Haster 75:dea0cdb42241 20 /**
Christopher Haster 75:dea0cdb42241 21 * A general socket address composed of the IP address and port
Christopher Haster 75:dea0cdb42241 22 */
Christopher Haster 75:dea0cdb42241 23 class SocketAddress {
Christopher Haster 75:dea0cdb42241 24 public:
Christopher Haster 75:dea0cdb42241 25 /** SocketAddress lifetime
Christopher Haster 75:dea0cdb42241 26 */
Christopher Haster 76:bbe51641f405 27 SocketAddress(const char *addr = 0, uint16_t port = 0);
Christopher Haster 76:bbe51641f405 28 SocketAddress(const SocketAddress &);
Christopher Haster 75:dea0cdb42241 29 ~SocketAddress();
Christopher Haster 75:dea0cdb42241 30
Christopher Haster 75:dea0cdb42241 31 /** Set the IP address
Christopher Haster 75:dea0cdb42241 32 \param host Null-terminated string representing the IP address
Christopher Haster 75:dea0cdb42241 33 */
Christopher Haster 76:bbe51641f405 34 void set_ip_address(const char *host);
Christopher Haster 75:dea0cdb42241 35
Christopher Haster 75:dea0cdb42241 36 /** Set the port
Christopher Haster 75:dea0cdb42241 37 \param port 16-bit port
Christopher Haster 75:dea0cdb42241 38 */
Christopher Haster 75:dea0cdb42241 39 void set_port(uint16_t port);
Christopher Haster 75:dea0cdb42241 40
Christopher Haster 75:dea0cdb42241 41 /** Get the IP address
Christopher Haster 75:dea0cdb42241 42 \return The string representation of the IP Address
Christopher Haster 75:dea0cdb42241 43 */
Christopher Haster 76:bbe51641f405 44 const char *get_ip_address();
Christopher Haster 75:dea0cdb42241 45
Christopher Haster 75:dea0cdb42241 46 /** Get the port
Christopher Haster 75:dea0cdb42241 47 \return The 16-bit port
Christopher Haster 75:dea0cdb42241 48 */
Christopher Haster 75:dea0cdb42241 49 int get_port(void);
Christopher Haster 75:dea0cdb42241 50 };
Christopher Haster 75:dea0cdb42241 51
Christopher Haster 75:dea0cdb42241 52 #endif