Home » Renegade Discussions » Mod Forum » Learn2IRC!
Re: Learn2IRC! [message #420188 is a reply to message #420116] |
Thu, 18 February 2010 04:49 |
|
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;
}
[Updated on: Thu, 18 February 2010 04:52] Report message to a moderator
|
|
|
|
|
Learn2IRC!
By: reborn on Wed, 17 February 2010 05:55
|
|
|
Re: Learn2IRC!
|
|
|
Re: Learn2IRC!
By: reborn on Wed, 17 February 2010 08:21
|
|
|
Re: Learn2IRC!
By: Sir Kane on Wed, 17 February 2010 10:56
|
|
|
Re: Learn2IRC!
|
|
|
Re: Learn2IRC!
By: reborn on Wed, 17 February 2010 14:06
|
|
|
Re: Learn2IRC!
By: raven on Wed, 17 February 2010 15:13
|
|
|
Re: Learn2IRC!
By: reborn on Wed, 17 February 2010 15:24
|
|
|
Re: Learn2IRC!
By: raven on Wed, 17 February 2010 15:28
|
|
|
Re: Learn2IRC!
By: Omar007 on Wed, 17 February 2010 15:41
|
|
|
Re: Learn2IRC!
By: Sir Kane on Thu, 18 February 2010 00:00
|
|
|
Re: Learn2IRC!
By: reborn on Thu, 18 February 2010 02:12
|
|
|
Re: Learn2IRC!
By: reborn on Thu, 18 February 2010 04:49
|
|
|
Re: Learn2IRC!
By: Omar007 on Thu, 18 February 2010 05:37
|
|
|
Re: Learn2IRC!
By: reborn on Thu, 18 February 2010 06:59
|
|
|
Re: Learn2IRC!
By: Omar007 on Thu, 18 February 2010 07:10
|
|
|
Re: Learn2IRC!
|
|
|
Re: Learn2IRC!
By: Omar007 on Thu, 18 February 2010 07:48
|
|
|
Re: Learn2IRC!
By: reborn on Thu, 18 February 2010 07:49
|
|
|
Re: Learn2IRC!
By: reborn on Thu, 18 February 2010 08:05
|
|
|
Re: Learn2IRC!
|
|
|
Re: Learn2IRC!
|
|
|
Re: Learn2IRC!
By: Omar007 on Thu, 18 February 2010 14:53
|
Goto Forum:
Current Time: Tue Dec 31 21:10:43 MST 2024
Total time taken to generate the page: 0.00992 seconds
|