Bonjour je me suis fais un petit programme irc qui me servira de bot pour auto-op des personne ou d'autre taches diverses, le client aura une boite de dialogue ou il pourrai voir ce que les gens ecrivent et un editbox pour ecrire (voir design d'xchat en gros)
mon probleme est que je ne sais pas comment mettre ma partie reception, pour que le reste de mon prog ne soit pas ignoré et qu'il n'y est pas un blocage sur la boucle
//partie reception
while(1)
{
recv(sock, buffer, sizeof(buffer), 0);
MessageBox(NULL,buffer,NULL,0);
memset(buffer,0,sizeof(buffer));
}
//code complet san la partie reception (ceci est le debut du code, les fonctions du futures bot n'ont pas été encore faites
#include <winsock2.h>
#include <windows.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "resource.h"
#define IRCIP "213.246.57.79"
#define PORT 4444
#define SALON "#code-fr"
#define NICK "Xperience"
#pragma comment(lib, "ws2_32.lib")
INT_PTR CALLBACK DlgProc(HWND, UINT, WPARAM, LPARAM);
HINSTANCE hinst;
int WINAPI WinMain(HINSTANCE Instance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow)
{
DialogBox(hinst,(LPCTSTR)IDD_DIALOG1, 0, DlgProc);
}
/******************************************************************************/
INT_PTR CALLBACK DlgProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
char buffer[5000];
WSADATA WSAData;
WSAStartup(MAKEWORD(2,0), &WSAData);
SOCKET sock;
SOCKADDR_IN sin;
sock = socket(AF_INET, SOCK_STREAM, 0);
sin.sin_addr.s_addr = inet_addr(IRCIP);
sin.sin_family = AF_INET;
sin.sin_port = htons(PORT);
connect(sock, (SOCKADDR *)&sin, sizeof(sin));
switch (uMsg)
{
case WM_INITDIALOG:
break;
case WM_COMMAND:
switch(wParam)
{
//envoi de texte
case IDC_BUTTON1:
send(sock, buffer, strlen(buffer), 0);
break;
}
break;
case WM_CLOSE:
EndDialog(hwnd, 1);
closesocket(sock);
WSACleanup();
break;
}
return 0;
}
.