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.
Fork of cc3000_hostdriver_mbedsocket by
Revision 32:e62d7252401e, committed 2013-10-06
- Comitter:
- Kojto
- Date:
- Sun Oct 06 18:25:12 2013 +0200
- Parent:
- 31:7b6e85b68b01
- Child:
- 33:9e23b24fb4f3
- Commit message:
- TCP/UDP client/server old implementation removal
Changed in this revision
| cc3000.cpp | Show annotated file Show diff for this revision Revisions of this file |
--- a/cc3000.cpp Sun Oct 06 18:01:19 2013 +0200
+++ b/cc3000.cpp Sun Oct 06 18:25:12 2013 +0200
@@ -282,89 +282,6 @@
}
#endif
-cc3000_client cc3000::create_tcp_client(uint32_t ip_address, uint16_t port) {
- sockaddr socket_address = {0};
- int32_t tcp_socket;
-
- tcp_socket = _socket.socket(AF_INET, SOCK_STREAM, IPPROTO_TCP);
- if (tcp_socket == -1) {
- DBG_CC("Failed to create new socket (tcp)");
- return cc3000_client(*this);
- }
-
- socket_address.family = AF_INET;
- socket_address.data[0] = (port & 0xFF00) >> 8;
- socket_address.data[1] = (port & 0x00FF);
- socket_address.data[2] = ip_address >> 24;
- socket_address.data[3] = ip_address >> 16;
- socket_address.data[4] = ip_address >> 8;
- socket_address.data[5] = ip_address;
-
- if (_socket.connect(tcp_socket, &socket_address, sizeof(socket_address)) == -1) {
- DBG_CC("Failed to connect (tcp)");
- _socket.closesocket(tcp_socket);
- return cc3000_client(*this);
- }
-
- return cc3000_client(*this, tcp_socket);
-}
-cc3000_client cc3000::create_udp_client(uint32_t ip_address, uint16_t port) {
- sockaddr socket_address = {0};
- int32_t udp_socket;
-
- udp_socket = _socket.socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP);
- if (udp_socket == -1) {
- DBG_CC("Failed to create new socket (udp)");
- return cc3000_client(*this);
- }
-
- socket_address.family = AF_INET;
- socket_address.data[0] = (port & 0xFF00) >> 8;
- socket_address.data[1] = (port & 0x00FF);
- socket_address.data[2] = ip_address >> 24;
- socket_address.data[3] = ip_address >> 16;
- socket_address.data[4] = ip_address >> 8;
- socket_address.data[5] = ip_address;
-
- if (_socket.connect(udp_socket, &socket_address, sizeof(socket_address)) == -1) {
- DBG_CC("Failed to connect (udp)");
- _socket.closesocket(udp_socket);
- return cc3000_client(*this);
- }
-
- return cc3000_client(*this, udp_socket);
-}
-
-cc3000_server cc3000::create_tcp_server(uint32_t ip_address, uint16_t port) {
- sockaddr socket_address = {0};
- int32_t tcp_socket;
-
- tcp_socket = _socket.socket(AF_INET, SOCK_STREAM, IPPROTO_TCP);
- if (tcp_socket == -1) {
- DBG_CC("Failed to create new socket.");
- return cc3000_server(*this, socket_address);
- }
-
- socket_address.family = AF_INET;
- socket_address.data[0] = (port & 0xFF00) >> 8;
- socket_address.data[1] = (port & 0x00FF);
- socket_address.data[2] = ip_address >> 24;
- socket_address.data[3] = ip_address >> 16;
- socket_address.data[4] = ip_address >> 8;
- socket_address.data[5] = ip_address;
-
- if (_socket.bind(tcp_socket, &socket_address, sizeof(socket_address)) != 0) {
- DBG_CC("Failed to bind the new socket");
- return cc3000_server(*this, socket_address);
- }
- if (_socket.listen(tcp_socket, 1) != 0) { /* 1 client */
- DBG_CC("Failed to listen on the new socket");
- return cc3000_server(*this, socket_address);
- }
-
- return cc3000_server(*this, socket_address, tcp_socket);
-}
-
void cc3000::delete_profiles(void) {
tUserFS user_info;
