School Assignment? Project Due Tomorrow? Chat LIVE With A Programming Expert!
Welcome to Dream.In.Code
Become an Expert!

Join 340,158 Programmers for FREE! Get instant access to thousands of experts, tutorials, code snippets, and more! There are 4,073 people online right now. Registration is fast and FREE... Join Now!



IRC Client

IRC Client Rate Topic: -----

#1 adamjon858  Icon User is offline

  • D.I.C Head
  • Icon
  • Group: Members w/DIC++
  • Posts: 167
  • Joined: 03-January 06


Dream Kudos: 20

Posted 25 July 2007 - 04:16 PM

A friend of mine and me are trying to get an IRC client together (it will be a special one just for our IRC network).

For some reason...I can't get it to do much:

#include <cstdlib>
#include <iostream>
#include <winsock.h>
#include <stdio.h>
#include "socketclass.h"


using std::string;
void get_buffer( void );
	cSocket SocketClass;
	string msg;
	string nick;
	char str[100];
	int x = 0;




using namespace std;

int main(int argc, char *argv[])
{



	
	if(  SocketClass.Connect( "irc.gameswitch.net", 6667) )
	{
		cout << "Socket Connected \n";
		CreateThread(NULL, 0, (LPTHREAD_START_ROUTINE)get_buffer, 0, 0, 0); 
		cout << "waiting for threads to join" << endl;
		
		nick = "irc.gameswitch.net USER \"bob.com\" \"irc.gameswitch.net\" :bob";
		strcpy(str, nick.c_str()); 
		SocketClass.Send(str);
		nick = "irc.gameswitch.net NICK superbob";
		strcpy(str, nick.c_str()); 
		SocketClass.Send(str);
		 nick = "NICK superbob";
		 strcpy(str, nick.c_str()); 
		SocketClass.Send(str);
		nick = "USER \"bob.com\" \"irc.gameswitch.net\" :bob";
		strcpy(str, nick.c_str()); 
		SocketClass.Send(str);
			
		while(1)
		{
			

										  
			 Sleep(500);
   

					
						
																				   
			
		}
	  //done?
	}
}


void get_buffer( void )
{
	  char stringsend[100];   
	  char buffer[2048];
	  
	  int buffersize;
	  int msglen = 0;
while(1)
{
	  buffersize = SocketClass.Receive( buffer );

			if(buffersize <= 0)
				   cout << "wth";   
				 
			for(int i = 0; i<buffersize; i++) 
			{
			   msg += buffer[i];
			   
			   if( buffer[i] == 10 )
			   {
				   cout << msg;
				   msglen = 0;
				   msg = "";
			   }
			   
			   if( buffer[i] == 58 )
			   {
				   cout << msg;
			   }
			   
			   if( buffer[i] == 80 )
			   {
				   cout << "Possible Ping";

			   msglen++;			   
			   }

			 }
}
}


Was This Post Helpful? 0
  • +
  • -


#2 snoj  Icon User is offline

  • Married Life
  • Icon
  • View blog
  • Group: Alumni
  • Posts: 3,474
  • Joined: 31-March 03


Dream Kudos: 775

Posted 25 July 2007 - 05:04 PM

So what are we suppose to do about that?
Was This Post Helpful? 0
  • +
  • -

#3 adamjon858  Icon User is offline

  • D.I.C Head
  • Icon
  • Group: Members w/DIC++
  • Posts: 167
  • Joined: 03-January 06


Dream Kudos: 20

Posted 26 July 2007 - 04:52 AM

lol...

What this program is supposed to do is connect to an IRC server.

Right now, it prints everything that is sent/received on the socket that connects to the IRC. My problem is that I can't get it to do anything other than have the the IRC server acknowledge that I am connected.

I try to identify myself but I get no answer.

What I receive from the server is printed like this:
NOTICE AUTH: ***Looking up your hostname
NOTICE AUTH: ***Found your hostname
NOTICE AUTH: ***Checking Ident

After this, normally I would be sent a PING :<number> that I would have to send back as PONG :<number>. Unfortunately, either theres an error with my program or it has a problem with me.

I would be very happy if you could help!
Was This Post Helpful? 0
  • +
  • -



Fast Reply

  

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users



Live Help!

Be Social

Dream.In.Code RSS Feed Dream.In.Code LinkedIn Group Follow Us On Twitter Fan Us On Facebook

Tutorials

Programming

Web Development

Reference Sheets

Code Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month