Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: DnsQuery
Dependents: WizFi310_TCP_Echo_Server_Example
Fork of NetworkSocketAPI by
Diff: TCPSocket.cpp
- Branch:
- api-changes
- Revision:
- 22:4fca633c0633
- Child:
- 24:a5e959bdd2dd
diff -r 35ed15069189 -r 4fca633c0633 TCPSocket.cpp
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/TCPSocket.cpp Thu Feb 18 03:29:39 2016 -0600
@@ -0,0 +1,62 @@
+/* TCPSocket
+ * 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 "TCPSocket.h"
+
+TCPSocket::TCPSocket(NetworkInterface *iface, const char *ip, uint16_t port)
+ : _iface(iface) {
+ _socket = _iface->createSocket(SOCK_TCP);
+
+ if (ip) setIPAddress(ip);
+ if (port) setPort(port);
+}
+
+TCPSocket::~TCPSocket() {
+ _iface->destroySocket(_socket);
+}
+
+void TCPSocket::setIPAddress(const char *ip) {
+ return _socket->setIPAddress(ip);
+}
+
+void TCPSocket::setPort(uint16_t port) {
+ return _socket->setPort(port);
+}
+
+const char *TCPSocket::getIPAddress() {
+ return _socket->getIPAddress();
+}
+
+uint16_t TCPSocket::getPort() {
+ return _socket->getPort();
+}
+
+int32_t TCPSocket::open() {
+ return _socket->open();
+}
+
+int32_t TCPSocket::close() {
+ return _socket->close();
+}
+
+int32_t TCPSocket::send(const void *data, uint32_t len, uint32_t timeout_ms) {
+ return _socket->send(data, len, timeout_ms);
+}
+
+int32_t TCPSocket::recv(void *data, uint32_t len, uint32_t timeout_ms) {
+ return _socket->recv(data, len, timeout_ms);
+}
+
