This commit is contained in:
Your Name 2023-11-02 19:17:12 +03:00
parent b29ae43dd6
commit 66599bc6bd
6 changed files with 97 additions and 8 deletions

View file

@ -1,8 +1,8 @@
#include "irc.h"
unsigned int IRCC_connect(IRCC_client *irc, const char *ip, const unsigned int port){
struct hostent *ghbn = gethostbyname(ip);
if (!ghbn)
struct hostent *hp = gethostbyname(ip);
if (!hp)
return IRCC_ERROR;
//Only ipv4
@ -10,7 +10,7 @@ unsigned int IRCC_connect(IRCC_client *irc, const char *ip, const unsigned int p
memset(&client_str, 0, sizeof(client_str));
client_str.sin_family = AF_INET;
client_str.sin_port = htons(port);
client_str.sin_addr.s_addr = inet_addr(inet_ntoa(*(struct in_addr *)ghbn->h_addr));
client_str.sin_addr.s_addr = inet_addr(inet_ntoa(*(struct in_addr *)hp->h_addr));
irc->socket = socket(AF_INET, SOCK_STREAM, 0);
if (irc->socket < 0)
@ -79,7 +79,7 @@ unsigned int IRCC_recv(IRCC_client *irc){
}
else {
//puts(irc->raw);
puts(irc->raw);
//Check end of motd
if (strstr(irc->raw, "PRIVMSG ") == NULL && strstr(irc->raw, "MOTD"))