change some parameters in the library to meet the needs of the website httpbin.org
Fork of MiniTLS-GPL by
Diff: socket/socket_lwip.c
- Revision:
- 3:eb324ffffd2b
- Parent:
- 2:527a66d0a1a9
--- a/socket/socket_lwip.c Mon Jun 09 14:57:54 2014 +0000 +++ b/socket/socket_lwip.c Tue Jun 10 14:22:36 2014 +0000 @@ -22,6 +22,11 @@ * \author Donatien Garnier */ +#define __DEBUG__ 4 +#ifndef __MODULE__ +#define __MODULE__ "socket_lwip.c" +#endif + #include "core/fwk.h" #include "socket.h" @@ -38,20 +43,22 @@ int socket_connect(int fd, const char* hostname, uint16_t port) { - /*struct hostent* hostent = gethostbyname(hostname); + struct hostent* hostent = lwip_gethostbyname(hostname); if(hostent == NULL) - { - return MINITLS_ERR_SOCKET_ERROR; - }*/ + { + WARN("Could not resolve %s\r\n", hostname); + return -1; + } struct sockaddr_in server; + memset(&server, 0, sizeof(struct sockaddr_in)); server.sin_family = AF_INET; - //memcpy(&server.sin_addr.s_addr, &hostent->h_addr_list[0], hostent->h_length); - server.sin_addr.s_addr = inet_addr(hostname); + memcpy(&server.sin_addr.s_addr, hostent->h_addr_list[0], hostent->h_length); + //server.sin_addr.s_addr = inet_addr(hostname); server.sin_port = htons(port); - DBG("Trying to connect to %s:%d", hostname, port); + DBG("Trying to connect to %s:%d", inet_ntoa(server.sin_addr.s_addr), port); - return lwip_connect(fd, (struct sockaddr*)&server, sizeof(struct sockaddr_in)); + return lwip_connect(fd, (const struct sockaddr*)&server, sizeof(struct sockaddr_in)); } int socket_wait_readable(int fd, int timeout_ms)