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:07:28 2016 -0500
Revision:
76:bbe51641f405
Parent:
75:dea0cdb42241
Child:
78:0914f9b9b24b
Added rough NetworkInterface

Who changed what in which revision?

UserRevisionLine numberNew contents of line
Christopher Haster 75:dea0cdb42241 1 /* Copyright (C) 2012 mbed.org, MIT License
Christopher Haster 75:dea0cdb42241 2 *
Christopher Haster 75:dea0cdb42241 3 * Permission is hereby granted, free of charge, to any person obtaining a copy of this software
Christopher Haster 75:dea0cdb42241 4 * and associated documentation files (the "Software"), to deal in the Software without restriction,
Christopher Haster 75:dea0cdb42241 5 * including without limitation the rights to use, copy, modify, merge, publish, distribute,
Christopher Haster 75:dea0cdb42241 6 * sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is
Christopher Haster 75:dea0cdb42241 7 * furnished to do so, subject to the following conditions:
Christopher Haster 75:dea0cdb42241 8 *
Christopher Haster 75:dea0cdb42241 9 * The above copyright notice and this permission notice shall be included in all copies or
Christopher Haster 75:dea0cdb42241 10 * substantial portions of the Software.
Christopher Haster 75:dea0cdb42241 11 *
Christopher Haster 75:dea0cdb42241 12 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING
Christopher Haster 75:dea0cdb42241 13 * BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
Christopher Haster 75:dea0cdb42241 14 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
Christopher Haster 75:dea0cdb42241 15 * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
Christopher Haster 75:dea0cdb42241 16 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
Christopher Haster 75:dea0cdb42241 17 */
Christopher Haster 76:bbe51641f405 18 #ifndef SOCKET_ADDRESS_H
Christopher Haster 76:bbe51641f405 19 #define SOCKET_ADDRESS_H
Christopher Haster 75:dea0cdb42241 20
Christopher Haster 75:dea0cdb42241 21 /**
Christopher Haster 75:dea0cdb42241 22 * A general socket address composed of the IP address and port
Christopher Haster 75:dea0cdb42241 23 */
Christopher Haster 75:dea0cdb42241 24 class SocketAddress {
Christopher Haster 75:dea0cdb42241 25 public:
Christopher Haster 75:dea0cdb42241 26 /** SocketAddress lifetime
Christopher Haster 75:dea0cdb42241 27 */
Christopher Haster 76:bbe51641f405 28 SocketAddress(const char *addr = 0, uint16_t port = 0);
Christopher Haster 76:bbe51641f405 29 SocketAddress(const SocketAddress &);
Christopher Haster 75:dea0cdb42241 30 ~SocketAddress();
Christopher Haster 75:dea0cdb42241 31
Christopher Haster 75:dea0cdb42241 32 /** Set the IP address
Christopher Haster 75:dea0cdb42241 33 \param host Null-terminated string representing the IP address
Christopher Haster 75:dea0cdb42241 34 */
Christopher Haster 76:bbe51641f405 35 void set_ip_address(const char *host);
Christopher Haster 75:dea0cdb42241 36
Christopher Haster 75:dea0cdb42241 37 /** Set the port
Christopher Haster 75:dea0cdb42241 38 \param port 16-bit port
Christopher Haster 75:dea0cdb42241 39 */
Christopher Haster 75:dea0cdb42241 40 void set_port(uint16_t port);
Christopher Haster 75:dea0cdb42241 41
Christopher Haster 75:dea0cdb42241 42 /** Get the IP address
Christopher Haster 75:dea0cdb42241 43 \return The string representation of the IP Address
Christopher Haster 75:dea0cdb42241 44 */
Christopher Haster 76:bbe51641f405 45 const char *get_ip_address();
Christopher Haster 75:dea0cdb42241 46
Christopher Haster 75:dea0cdb42241 47 /** Get the port
Christopher Haster 75:dea0cdb42241 48 \return The 16-bit port
Christopher Haster 75:dea0cdb42241 49 */
Christopher Haster 75:dea0cdb42241 50 int get_port(void);
Christopher Haster 75:dea0cdb42241 51 };
Christopher Haster 75:dea0cdb42241 52
Christopher Haster 75:dea0cdb42241 53 #endif