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:
Mon Feb 22 19:07:36 2016 -0600
Branch:
api-changes
Revision:
32:2c5fc105fc50
Parent:
28:163fbe3263f4
Child:
43:09ea32f2eb54
Added open/close calls to all sockets

Who changed what in which revision?

UserRevisionLine numberNew contents of line
Christopher Haster 21:35ed15069189 1 /* TCPSocket
Christopher Haster 21:35ed15069189 2 * Copyright (c) 2015 ARM Limited
Christopher Haster 21:35ed15069189 3 *
Christopher Haster 21:35ed15069189 4 * Licensed under the Apache License, Version 2.0 (the "License");
Christopher Haster 21:35ed15069189 5 * you may not use this file except in compliance with the License.
Christopher Haster 21:35ed15069189 6 * You may obtain a copy of the License at
Christopher Haster 21:35ed15069189 7 *
Christopher Haster 21:35ed15069189 8 * http://www.apache.org/licenses/LICENSE-2.0
Christopher Haster 21:35ed15069189 9 *
Christopher Haster 21:35ed15069189 10 * Unless required by applicable law or agreed to in writing, software
Christopher Haster 21:35ed15069189 11 * distributed under the License is distributed on an "AS IS" BASIS,
Christopher Haster 21:35ed15069189 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
Christopher Haster 21:35ed15069189 13 * See the License for the specific language governing permissions and
Christopher Haster 21:35ed15069189 14 * limitations under the License.
Christopher Haster 21:35ed15069189 15 */
Christopher Haster 21:35ed15069189 16
Christopher Haster 21:35ed15069189 17 #ifndef TCP_SOCKET_H
Christopher Haster 21:35ed15069189 18 #define TCP_SOCKET_H
Christopher Haster 21:35ed15069189 19
Christopher Haster 25:ed7b2a52e8ac 20 #include "Socket.h"
Christopher Haster 21:35ed15069189 21
Christopher Haster 21:35ed15069189 22 /** TCPSocket class
Christopher Haster 21:35ed15069189 23 * API for handling TCP sockets. The implementation is determined
Christopher Haster 21:35ed15069189 24 * by the interface passed during construction.
Christopher Haster 21:35ed15069189 25 */
Christopher Haster 25:ed7b2a52e8ac 26 class TCPSocket : public Socket
Christopher Haster 21:35ed15069189 27 {
Christopher Haster 21:35ed15069189 28 public:
Christopher Haster 21:35ed15069189 29 /** Create a socket using the specified network interface
Christopher Haster 27:d7ed39727306 30 * No network operations are performed until the socket is actually used
Christopher Haster 21:35ed15069189 31 * @param iface The network interface to use
Christopher Haster 27:d7ed39727306 32 * @param url Optional URL to connect to, copied internally
Christopher Haster 21:35ed15069189 33 * @param port Optional port to connect to
Christopher Haster 21:35ed15069189 34 */
Christopher Haster 28:163fbe3263f4 35 TCPSocket(NetworkInterface *iface);
Christopher Haster 21:35ed15069189 36 };
Christopher Haster 21:35ed15069189 37
Christopher Haster 21:35ed15069189 38 #endif