Renegade Public Forums
C&C: Renegade --> Dying since 2003™, resurrected in 2024!
Home » Renegade Discussions » Mod Forum » Learn2IRC!
Re: Learn2IRC! [message #420188 is a reply to message #420116] Thu, 18 February 2010 04:49 Go to previous messageGo to previous message
reborn is currently offline  reborn
Messages: 3231
Registered: September 2004
Location: uk - london
Karma:
General (3 Stars)
Ok, so I got a little further... Basically the IRC server sends a shit tonne of information when you choose your nick (see screenshot below). However, after choosing my nick and receiving all the crap from the server, I try to join a channel, I send the command, and try to receive the response, but it doesn't actually respond, and I don't join the channel.


DWORD WINAPI MainThread( LPVOID lpParam ){

char buf1[4096];
char nick[] = "rebot";
char text1[4096];
int n;

 
WORD wsver=MAKEWORD(2, 0);

int nret=WSAStartup(wsver, &wsaData);
if(nret != 0){
	printf("Startup failed, error code: %d\n",WSAGetLastError());
	WSACleanup();
	return false;
}

printf("Init success\n");
SOCKET kSock=socket(AF_INET, SOCK_STREAM, 0);


if(kSock == INVALID_SOCKET){
	printf("Socket init failed");
	return false;
}

printf("Socket initialized\n");

sockaddr_in sin;

sin.sin_port=htons(6668);

sin.sin_addr.s_addr=inet_addr("85.25.143.169");

sin.sin_family=AF_INET;

if(connect(kSock,(sockaddr*)&sin, sizeof(sin)) == SOCKET_ERROR){
	printf("Startup failed, error code: %d\n",WSAGetLastError());
	WSACleanup();
	return false;
}
printf("Connection successful!\n\n");

n = recv(kSock, buf1, 4096, 0);
if ( n > 0 ) {
	printf(">>Server: %s\n",buf1);
	}
else {
	printf(">>Server: No Data\n");
}



sprintf(text1, "NICK rebot2\r\nUSER rebot2 0 0 :rebot2\r\n");
send(kSock, text1, strlen(text1), 0);
printf(">>Client: %s\n",text1);

n = recv(kSock, buf1, 4096, 0);
if ( n > 0 ) {
	printf(">>Server: %s\n",buf1);
	if (strstr(buf1,"PING")){
		printf("I got a ping, cool!\n");
		char* myStringPtr = buf1;
		myStringPtr+=6;
				char * pch;
		pch = strtok (myStringPtr,"	 =\n");
		std::vector<std::string> str_Vector;
		while (pch != NULL){
		std::string strData = pch;
		str_Vector.push_back(strData);
		pch = strtok (NULL, "	 =\n");
		}
		sprintf(text1,"PONG :%s\r\n",str_Vector.at(0).c_str());
		send(kSock, text1, sizeof(text1), 0);
		printf(">>Client: %s\n",text1);
	}
	}
else {
	printf(">>Server: No Data\n");
}

n = recv(kSock, buf1, 4096, 0);
if ( n > 0 ) {
	printf(">>Server: %s\n",buf1);
	}
else {
	printf(">>Server: No Data\n");
}


n = recv(kSock, buf1, 4096, 0);
if ( n > 0 ) {
	printf(">>Server: %s\n",buf1);
	}
else {
	printf(">>Server: No Data\n");
}

n = recv(kSock, buf1, 4096, 0);
if ( n > 0 ) {
	printf(">>Server: %s\n",buf1);
	}
else {
	printf(">>Server: No Data\n");
}

n = recv(kSock, buf1, 4096, 0);
if ( n > 0 ) {
	printf(">>Server: %s\n",buf1);
	}
else {
	printf(">>Server: No Data\n");
}



sprintf(text1,"JOIN #lobby\r\n");
send(kSock, text1, sizeof(text1), 0);
printf(">>Client: %s\n",text1);
n = recv(kSock, buf1, 4096, 0);
if ( n > 0 ) {
	printf(">>Server: %s\n",buf1);
	}
else {
	printf(">>Server: No Data\n");
}



/*
sprintf(text1,"PRIVMSG #lobby :Test Message\r\n");
send(kSock,text1,sizeof(text1),0);
printf(">>Client: %s\n",text1);

n = recv(kSock, buf1, 4096, 0);
if ( n > 0 ) {
	printf(">>Server: %s\n",buf1);
	}
else {
	printf(">>Server: No Data\n");
}



*/
/*
 // ping and pong, will obviously be moved...
while (1) {
recv( kSock,buf,255,0);
if (strstr(buf,"PING")) {
	printf("Server sent PING\n");
	send(kSock,"PONG :\r\n",128,0);
	printf("Replying with PONG\n");
}
else{
	printf(">>Server: %s\n",buf);
}
}
*/
return 1;
}



http://www.game-maps.net/staff/reborn/rebot2.JPG



[Updated on: Thu, 18 February 2010 04:52]

Report message to a moderator

 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: .lsd and .ldd .dbb... What should I use?
Next Topic: How do i remove...
Goto Forum:
  


Current Time: Tue Dec 31 21:10:43 MST 2024

Total time taken to generate the page: 0.00992 seconds