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.
Revision 111:df01ca3e89b3, committed 2016-04-20
- Comitter:
- Christopher Haster
- Date:
- Wed Apr 20 02:56:07 2016 -0500
- Parent:
- 110:58aea4713a41
- Child:
- 112:e0cbb3e43c20
- Commit message:
- Add workaround for bug in newlib scanf
https://bugs.launchpad.net/gcc-arm-embedded/+bug/1399224
Changed in this revision
SocketAddress.cpp | Show annotated file Show diff for this revision Revisions of this file |
--- a/SocketAddress.cpp Tue Apr 19 20:09:46 2016 -0500 +++ b/SocketAddress.cpp Wed Apr 20 02:56:07 2016 -0500 @@ -56,7 +56,23 @@ static void ipv4_from_address(uint8_t *bytes, const char *addr) { - sscanf(addr, "%hhu.%hhu.%hhu.%hhu", &bytes[0], &bytes[1], &bytes[2], &bytes[3]); + int count = 0; + int i = 0; + + for (; count < NSAPI_IPv4_BYTES; count++) { + int scanned = sscanf(&addr[i], "%hhu", &bytes[count]); + if (scanned < 1) { + return; + } + + for (; addr[i] != '.'; i++) { + if (!addr[i]) { + return; + } + } + + i++; + } } static int ipv6_scan_chunk(uint16_t *shorts, const char *chunk) {