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
Diff: Socket/UDPSocket.cpp
- Revision:
- 5:245ac5b73132
- Parent:
- 4:15b58c119a0a
- Child:
- 10:7069c5f1e6f4
--- a/Socket/UDPSocket.cpp Sat Sep 21 15:01:05 2013 +0000 +++ b/Socket/UDPSocket.cpp Thu Sep 26 19:50:37 2013 +0000 @@ -1,4 +1,4 @@ -/* Copyright (C) 2012 mbed.org, MIT License +/* Copyright (C) 2013 mbed.org, MIT License * * Permission is hereby granted, free of charge, to any person obtaining a copy of this software * and associated documentation files (the "Software"), to deal in the Software without restriction, @@ -29,7 +29,6 @@ return init_socket(SOCK_DGRAM, IPPROTO_UDP); } -// Server initialization int UDPSocket::bind(int port) { if (init_socket(SOCK_DGRAM, IPPROTO_UDP) < 0) { return -1; @@ -41,14 +40,6 @@ localHost.sin_family = AF_INET; localHost.sin_port = htons(port); localHost.sin_addr.s_addr = 0; - // sockaddr localHost; - // localHost.family = AF_INET; - // localHost.data[0] = (port & 0xFF00)>> 8; - // localHost.data[1] = (port & 0x00FF); - // localHost.data[2] = 0; - // localHost.data[3] = 0; - // localHost.data[4] = 0; - // localHost.data[5] = 0; if (_cc3000_module->_socket.bind(_sock_fd, (sockaddr *)&localHost, sizeof(sockaddr_in)) != 0) { #if (CC3000_DEBUG == 1) @@ -58,13 +49,10 @@ _sock_fd = -1; return -1; } -// #if (CC3000_DEBUG == 1) -// printf("DEBUG: local add: %d\n",localHost.sin_addr.s_addr); -// #endif + return 0; } -// -1 if unsuccessful, else number of bytes written int UDPSocket::sendTo(Endpoint &remote, char *packet, int length) { if (_sock_fd < 0) { @@ -84,7 +72,6 @@ return _cc3000_module->_socket.sendto(_sock_fd, packet, length, 0, (sockaddr *)&remote._remote_host, sizeof(sockaddr)); } -// -1 if unsuccessful, else number of bytes received int UDPSocket::receiveFrom(Endpoint &remote, char *buffer, int length) { if (_sock_fd < 0) {