Message-ID: <001e01c0e241$6592e050$96f5edc8@Soft150> From: =?iso-8859-1?Q?J=FAlio_Adrian_Mi=F1o_Van_Helden?= To: Subject: Compiling socket client in win32 System Date: Mon, 21 May 2001 19:00:07 -0300 MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="----=_NextPart_000_001B_01C0E228.40366610" X-Priority: 3 X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook Express 5.50.4133.2400 X-MimeOLE: Produced By Microsoft MimeOLE V5.50.4133.2400 Reply-To: djgpp AT delorie DOT com This is a multi-part message in MIME format. ------=_NextPart_000_001B_01C0E228.40366610 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable I need to compile this ipc program on win32 but i can't find any port = for socket.h on win32 system without change the code. #include #include #include =20 #include =20 #include =20 #include =20 =20 main ( int argc, char *argv[ ] )=20 {=20 int cont,cria_socket;=20 int bufsize =3D 1024;=20 char *buffer =3D malloc(bufsize);=20 struct sockaddr_in address;=20 if ((cria_socket =3D socket(AF_INET,SOCK_STREAM,0)) > 0)=20 printf("O socket foi criado\n"); else printf("Erro na cria=E7=E3o do Socket\n"); address.sin_family =3D AF_INET;=20 address.sin_addr.s_addr =3D INADDR_ANY;=20 address.sin_port =3D htons(80);=20 if (connect(cria_socket,(struct sockaddr *)&address, sizeof(address)) = =3D=3D 0)=20 printf("A conexao Foi aceita\n");=20 else printf("Conexao recusada\n"); =20 for (cont=3D1;cont<2;cont++)=20 { =20 printf("Mensagem a enviar: "); gets(buffer);=20 send(cria_socket,buffer,bufsize,0);=20 recv(cria_socket,buffer,bufsize,0);=20 printf("Mensagem recebida: %s\n",buffer);=20 }=20 close(cria_socket);=20 printf("Socket Fechado: ");=20 }=20 ------=_NextPart_000_001B_01C0E228.40366610 Content-Type: text/html; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable
I need to compile this ipc program on = win32 but i=20 can't find any port for socket.h on win32 system without change the=20 code.
 
#include = <sys/socket.h>
#include=20 <sys/types.h>
#include <netinet/in.h>
#include=20 <unistd.h>
#include <stdlib.h>
#include = <stdio.h>=20
 
main ( int argc, char *argv[ ] )
{
   = int=20 cont,cria_socket;
   int bufsize =3D 1024; =
   char=20 *buffer =3D  malloc(bufsize);
   struct sockaddr_in = address;=20
   if ((cria_socket =3D socket(AF_INET,SOCK_STREAM,0)) = > 0)=20
     printf("O socket foi = criado\n");
  =20 else
     printf("Erro na cria=E7=E3o do=20 Socket\n");
   address.sin_family =3D AF_INET; =
  =20 address.sin_addr.s_addr =3D INADDR_ANY;
   = address.sin_port =3D=20 htons(80);
   if (connect(cria_socket,(struct sockaddr=20 *)&address, sizeof(address)) =3D=3D 0)
     = printf("A=20 conexao Foi aceita\n");
   = else
    =20 printf("Conexao recusada\n");
     =
   for=20 (cont=3D1;cont<2;cont++)
    {  =20
        printf("Mensagem a = enviar:=20 ");
        gets(buffer);=20
       =20 send(cria_socket,buffer,bufsize,0);=20
       =20 recv(cria_socket,buffer,bufsize,0);=20
        printf("Mensagem = recebida:=20 %s\n",buffer);
 
     } =
  =20 close(cria_socket);
   printf("Socket Fechado: ");
}=20
------=_NextPart_000_001B_01C0E228.40366610--