- #include <windows.h>
- #include <winsock.h>
-
- #define C_BON 1
- #define ERR_LISTEN 16
- #define ERR_BIND 11
-
- int Attendre(SOCKET *s, SOCKADDR_IN *info, int port) {
- int err;
-
- info->sin_family = AF_INET;
- info->sin_port = htons(port);
- info->sin_addr.s_addr = INADDR_ANY;
-
- if ((*s = socket(AF_INET, SOCK_STREAM, 0)) == -1)
- {
- return ERR_CREATION_SOCKET;
- }
- if ((err = bind(*s, (struct sockaddr *)info, sizeof(*info))) == -1)
- {
- return ERR_BIND;
- } else {
- if ((err = listen(*s, 5)) == -1)
- {
- return ERR_LISTEN;
- }
- }
- }
#include <windows.h>
#include <winsock.h>
#define C_BON 1
#define ERR_LISTEN 16
#define ERR_BIND 11
int Attendre(SOCKET *s, SOCKADDR_IN *info, int port) {
int err;
info->sin_family = AF_INET;
info->sin_port = htons(port);
info->sin_addr.s_addr = INADDR_ANY;
if ((*s = socket(AF_INET, SOCK_STREAM, 0)) == -1)
{
return ERR_CREATION_SOCKET;
}
if ((err = bind(*s, (struct sockaddr *)info, sizeof(*info))) == -1)
{
return ERR_BIND;
} else {
if ((err = listen(*s, 5)) == -1)
{
return ERR_LISTEN;
}
}
}