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.
Dependents: cc3000_hello_world_demo cc3000_simple_socket_demo cc3000_ntp_demo cc3000_ping_demo ... more
Diff: Socket/Endpoint.cpp
- Revision:
- 34:1ad18123bf11
- Parent:
- 18:7e22775eadb9
- Child:
- 45:50ab13d8f2dc
--- a/Socket/Endpoint.cpp Tue Oct 08 07:04:07 2013 +0200
+++ b/Socket/Endpoint.cpp Tue Oct 08 13:13:05 2013 +0200
@@ -95,23 +95,14 @@
//Resolve DNS address or populate hard-coded IP address
uint32_t address_integer;
resolveRetCode = _cc3000_module->_socket.gethostbyname((uint8_t *)host, strlen(host) , &address_integer);
-
- if ((resolveRetCode > -1) && ( 0 != address_integer ))
- {
- // Resolved address
- uint32_t ip = 0;
- ip = (ip | (address_integer >> 24));
- ip = (ip | ((address_integer & 0x00FF0000) >> 8));
- ip = (ip | ((address_integer & 0x0000FF00) << 8));
- ip = (ip | ((address_integer & 0x000000FF) << 24));
- _remote_host.sin_addr.s_addr = ip;
+
+ if ((resolveRetCode > -1) && (0 != address_integer)) {
+ _remote_host.sin_addr.s_addr = htonl(address_integer);
inet_ntoa_r(_remote_host.sin_addr, _ipAddress, sizeof(_ipAddress));
- }
- else
- {
+ } else {
// Failed to resolve the address
DBG_SOCKET("Failed to resolve the hostname : %s",host);
- return ( -1 );
+ return (-1);
}
} else {
std::memcpy((char*)&_remote_host.sin_addr.s_addr, p_address, 4);
@@ -127,7 +118,7 @@
int((_remote_host.sin_addr.s_addr & 0xFF0000) >> 16),
int((_remote_host.sin_addr.s_addr & 0xFF000000) >> 24));
DBG_SOCKET("port: %d", port);
-
+
return 0;
}
SimpleLink Wi-Fi CC3000
Avnet Wi-Go System