Bonjour, bonjour!
J'ai récemment créé une petite application client/serveur de rien du tout (je suis débutant), en m'aidant de ça : http://c.developpez.com/WalrusSock/ et ce que j'ai réalisé ne marche pas, du moins pas jusqu'a la fin.
Au moment de la boucle pour récupérer le send du client je m'enmèle enfin bref, ça ne marche pas! Vous pouvez essayer.
PS : Je ne cherche pas a faire un truc compliqué avec des "threads" (????) et tout ^^
Le code :
---- Client, marche parfaitement (je crois) ----
#include <stdio.h>
#include <stdlib.h>
#pragma comment(lib, "ws2_32.lib")
#include <winsock2.h>
#define true 1
#define false 0
typedefintbool;
int main(int argc, char *argv[])
{
printf("\n ----------------- \n |Chat Client v0.1|\n ----------------- \n\n IP : ");
char ip [14];
scanf("%s", &ip);
fflush(stdin);
printf(" IP = OK\n\n");
int port;
choix : printf(" Connect now? [1 : Yes/2 : No] => ");
char yesno;
scanf("%ld", &yesno);
fflush(stdin);
switch (yesno)
{
case1:
printf(" Initializing connection socket...\n");
WSADATA WSAData;
WSAStartup(MAKEWORD(2,0), &WSAData);
SOCKET sock;
SOCKADDR_IN sin;
char buffer[255];
printf(" Loading adresses...\n");
sock = socket(AF_INET, SOCK_STREAM, 0);
sin.sin_addr.s_addr = inet_addr(ip);
sin.sin_family = AF_INET;
sin.sin_port = htons(312);
printf(" Connecting on port 312...");
bool bool1 = true;
while (bool1 == true)
{
int sinsize = sizeof(sin);
if((sock = connect(sock, (SOCKADDR *)&sin, &sinsize)) != INVALID_SOCKET)
{
bool1 == false;
printf(" Connected !");
send(sock, "Connected with Client v0.1\r\n", 28, 0);
}
}
break;
case2:
printf("\n No problem, bye!\n");
break;
default:
printf(" Invalid command ! Retry.\n\n");
goto choix;
break;
}
printf("\n\n\n\n\n\n\n\n\n ");
system("PAUSE");
return0;
---- Serveur, lui bug ----
#include <stdio.h>
#include <stdlib.h>
#pragma comment(lib, "ws2_32.lib")
#include <winsock2.h>
#define true 1
#define false 0
typedefintbool;
int main(int argc, char *argv[])
{
printf("\n ------------------\n |Chat Server v0.1|\n ------------------\n\n");
printf(" Initializating...");
WSADATA WSAData;
WSAStartup(MAKEWORD(2,0), &WSAData);
SOCKET sock;
SOCKET csock;
SOCKADDR_IN sin;
SOCKADDR_IN csin;
sock = socket(AF_INET, SOCK_STREAM, 0);
printf("\n Entering adresses...");
sin.sin_addr.s_addr = INADDR_ANY;
sin.sin_family = AF_INET;
sin.sin_port = htons(312);
printf("\n Binding...");
bind(sock, (SOCKADDR *)&sin, sizeof(sin));
listen(sock, 0);
bool bool1 = true;
printf("\n Listening...");
while(bool1 == true)
{
int sinsize = sizeof(csin);
if((csock = accept(sock, (SOCKADDR *)&csin, &sinsize)) != INVALID_SOCKET)
{
bool1 = false;
printf(" Somebody is connected !\n\n ");
bool bool2 = true;
while (bool2 == true) // A partir de là.
{
char buffer[255];
memset(buffer, "/r", sizeof(buffer));
recv(csock, buffer, sizeof(buffer), 0);
if (buffer != "");
{
bool2 = false;
printf(" Client message : %s\n",buffer);
}
}
}
}
system("PAUSE");
return0;
}
Ca serait cool de m'aider 
Merci d'avance !!