ap

Dependencies:   DnsQuery

Dependents:   WizFi310_TCP_Echo_Server_Example

Fork of NetworkSocketAPI by NetworkSocketAPI

Branch:
api-changes
Revision:
22:4fca633c0633
Child:
24:a5e959bdd2dd
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/UDPSocket.cpp	Thu Feb 18 03:29:39 2016 -0600
@@ -0,0 +1,54 @@
+/* UDPSocket
+ * 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 "UDPSocket.h"
+
+UDPSocket::UDPSocket(NetworkInterface *iface, const char *ip, uint16_t port)
+  : _iface(iface) {
+    _socket = _iface->createSocket(SOCK_UDP);
+
+    if (ip)   setIPAddress(ip);
+    if (port) setPort(port);
+}
+
+UDPSocket::~UDPSocket() {
+    _iface->destroySocket(_socket);
+}
+
+void UDPSocket::setIPAddress(const char *ip) {
+    return _socket->setIPAddress(ip);
+}
+
+void UDPSocket::setPort(uint16_t port) {
+    return _socket->setPort(port);
+}
+
+const char *UDPSocket::getIPAddress() {
+    return _socket->getIPAddress();
+}
+
+uint16_t UDPSocket::getPort() {
+    return _socket->getPort();
+}
+
+int32_t UDPSocket::send(const void *data, uint32_t len, uint32_t timeout_ms) {
+    return _socket->send(data, len, timeout_ms);
+}
+
+int32_t UDPSocket::recv(void *data, uint32_t len, uint32_t timeout_ms) {
+    return _socket->recv(data, len, timeout_ms);
+}
+