1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48
|
#include <winsock2.h>
#include <stdio.h>
#include <stdlib.h>
int main()
{
WSADATA WSAData;
WSAStartup(MAKEWORD(2,2), &WSAData);
int err;
char log[] = {"user monLogin"};
char pass[] = {"pass monMotDePasse"};
char *buff,*buff2;
SOCKET sock;
SOCKADDR_IN sin;
buff = malloc(100*sizeof(char));
buff2 = malloc(100*sizeof(char));
sock = socket(PF_INET,SOCK_STREAM,0);
if(sock != INVALID_SOCKET)
{
sin.sin_family = AF_INET;
sin.sin_port = htons(995);
sin.sin_addr.s_addr = inet_addr("209.85.229.109");
if(connect(sock,(SOCKADDR_IN*)&sin,sizeof(sin)) != SOCKET_ERROR)
{
printf("Connexion à %s sur le port %d\n", inet_ntoa(sin.sin_addr), htons(sin.sin_port));
err = send(sock,log,sizeof(log),0);
if(err != SOCKET_ERROR)
{
printf("Log envoyer\n");
}
err =recv(sock,buff2,sizeof(buff2),0);
if(err != SOCKET_ERROR)
{
printf("Chaine recu : %s\n",buff2);
}
}
}
} |
Partager