All pastes #947624 Raw Edit

NEW CODE

public cpp v1 · immutable
·published 2008-03-18 16:44 UTC
rendered paste body
#include <windows.h>#include "resource.h"#define PORT 6667LRESULT CALLBACK ClientDlgProc(HWND DialogWindow, UINT Message, WPARAM wParam, LPARAM lParam){	switch(Message)	{	WSADATA WSAData;	WSAStartup(MAKEWORD(2,0), &WSAData);  //Winsock 2.0	SOCKET connection;//this is a socket named 'connection'	SOCKADDR_IN sin;	connection = socket(AF_INET, SOCK_STREAM, 0); //'connection' is a stream socket	struct hostent *he;	char iptext[100]; 	{ HWND a = GetDlgItem(DialogWindow,IDC_ADDRESS); 	GetWindowText(a,iptext,sizeof(iptext)); }	if ((he = gethostbyname(iptext)) == NULL) //get the ip of parameter 1 in command prompt	{		perror("gethostbyname"); //if there is a problem in gethostbyname, print the error		exit(EXIT_FAILURE);	}		sin.sin_addr			= *((struct in_addr *)he->h_addr); //address to connect to		sin.sin_family			= AF_INET;						   //potocol AF_INET is everything		sin.sin_port			= htons(PORT);                     //the port the irc server has open for connections	    memset(&(sin.sin_zero), '\0', 8);	case WM_INITDIALOG:		return FALSE;		break;	case WM_COMMAND:		switch(wParam)		{		case IDC_Connect:			{		char *nick		= "NICK nanobot\r\n"; 		char *channel	= "JOIN #social\r\n"; 		char *user      = "USER nanobot nanobot nanobot :nanobot bot\r\n";		char *entermsg  = "PRIVMSG #test :[-]![-]\r\n";		char *exitmsg	= "PRIVMSG #test :[-]Exit...[-]\r\n";		char buf[512];		connect(connection, (SOCKADDR*)&sin, sizeof(sin));		send(connection,nick,strlen(nick),0);		send(connection,user,strlen(user),0);		do		{			recv(connection,buf,512,0);			if (strncmp("PING", buf, 4) == 0)			{				SetWindowText(IDC_StatusBox,"[-]Received PING... Sending PONG\n");				buf[1] = 'O';				send(connection, buf, strlen(buf), 0);			}			if (strncmp("End of /MOTD command.", buf, sizeof(buf)))			{				send(connection,channel,strlen(channel),0);				Sleep(1000);			}			SetWindowText(IDC_StatusBox, connection);		}while(1);			}		case IDCANCEL:			EndDialog(DialogWindow, FALSE);			return FALSE;			break;		default:			break;		}		break;		default:			break;	}	return FALSE;}int APIENTRYWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdline, int nCmdShow){	DialogBox((HINSTANCE) hInstance, MAKEINTRESOURCE(IDD_CLIENT), NULL, (DLGPROC) ClientDlgProc);	return 0;}