From 9b2a5837b18b27af3fcc9a25ba600ea7fb234ee6 Mon Sep 17 00:00:00 2001 From: brain Date: Sun, 18 Nov 2007 10:46:59 +0000 Subject: Test framework connects now git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@8603 e03df62e-2008-0410-955e-edbf42e46eb7 --- src/modules/m_remoteinclude_http.cpp | 29 +++++++++++++++++++++++++---- 1 file 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; } -- cgit v1.2.3