int socket(int Famille, int Type, int Protocole);
Le type Type est le suivant :
#include <stdio.h>
#include <socket.h>
int Socquette;
int SocquetteClient;
struct sockaddr_in Adresse;
int Taille;
char Buffer[100];
Taille=sizeof(struct sockaddr_in);
Socquette=socket(AF_INET, SOCK_STREAM, 0);
if (Socquette<0)
{
...
}
...
Adresse.sin_family=AF_UNIX;
Adresse.sin_port=(unsigned short)80;
Adresse.sin_addr.S_un.S_un_b.s_b1=(unsigned char)127;
Adresse.sin_addr.S_un.S_un_b.s_b2=(unsigned char)0;
Adresse.sin_addr.S_un.S_un_b.s_b3=(unsigned char)0;
Adresse.sin_addr.S_un.S_un_b.s_b4=(unsigned char)1;
...
if (bind(Socquette, (struct sockaddr *)&Adresse, Taille)<0)
{
...
}
...
if (listen(Socquette, 10)<0)
{
...
}
...
memset(&Adresse, 0, Taille);
SoquetteClient=accept(Socquette, (struct sockaddr *)&Adresse, Taille);
if (SocquetteClient<0)
{
...
}
...
memset(Buffer, 0, 100);
if (recv(SocquetteClient, Buffer, 100, 0)<0)
{
...
}
...
if (send(SocquetteClient, Buffer, 100, 0)<0)
{
...
}
...
if (shutdown(Socquette, 0x2)<0)
{
...
}
...