diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/modules/m_remoteinclude_http.cpp | 29 |
1 files changed, 25 insertions, 4 deletions
diff --git a/src/modules/m_remoteinclude_http.cpp b/src/modules/m_remoteinclude_http.cpp index 1aa2ba7b4..c8dc3c2b2 100644 --- a/src/modules/m_remoteinclude_http.cpp +++ b/src/modules/m_remoteinclude_http.cpp @@ -47,30 +47,51 @@ class ModuleRemoteIncludeHttp : public Module server = gethostbyname("neuron.brainbox.winbot.co.uk"); sockfd = socket(AF_INET, SOCK_STREAM, 0); - if (sockfd < 0) + if (sockfd < 0) + { + ServerInstance->Log(DEBUG,"Failed to socket()"); return 0; + } if (server == NULL) + { + ServerInstance->Log(DEBUG,"No such host"); return 0; + } memset(&serv_addr, sizeof(serv_addr), 0); serv_addr.sin_family = AF_INET; - memcpy(server->h_addr, &serv_addr.sin_addr.s_addr, server->h_length); + memcpy(&serv_addr.sin_addr.s_addr, server->h_addr, server->h_length); serv_addr.sin_port = htons(portno); if (connect(sockfd, (const sockaddr*)&serv_addr, sizeof(serv_addr)) < 0) + { + ServerInstance->Log(DEBUG,"Failed to connect()"); return 0; + } - n = send(sockfd, "GET / HTTP/1.0\r\n", 16, 0); + ServerInstance->Log(DEBUG,"Connected to brainbox"); + + n = send(sockfd, "GET / HTTP/1.0\r\n\r\n", 18, 0); if (n < 0) + { + ServerInstance->Log(DEBUG,"Failed to send()"); return 0; + } + + ServerInstance->Log(DEBUG,"Sent GET request"); - n = read(sockfd,buffer,255); + n = read(sockfd,buffer,1); if (n < 1) + { + ServerInstance->Log(DEBUG,"Failed to read()"); return 0; + } + + ServerInstance->Log(DEBUG,"Read one byte"); return 1; } |