Advertisement
Guest User

Untitled

a guest
May 6th, 2015
216
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.66 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include <unistd.h>
  4. #include <errno.h>
  5. #include <string.h>
  6. #include <netdb.h>
  7. #include <sys/types.h>
  8. #include <netinet/in.h>
  9. #include <sys/socket.h>
  10.  
  11. int main (void)
  12. {
  13.     int fd;
  14.     struct sockaddr_in mio_indirizzo;
  15.     char buff0[100];
  16.     mio_indirizzo.sin_family = AF_INET;
  17.     mio_indirizzo.sin_port = htons(5200);
  18.     mio_indirizzo.sin_addr.s_addr=inet_addr("93.40.208.13");
  19.    
  20.     fd = socket(AF_INET,SOCK_STREAM,0);
  21.     printf("fd= %d",fd);
  22.     connect(fd,(struct sockaddr *)&mio_indirizzo, sizeof(mio_indirizzo));
  23.     write(1,"cosaInviare?\n",13);
  24.     int r=read(0,buff0,100);
  25.     buff0[r-1]='\0';
  26.     write(fd,buff0,r);
  27.     close (fd);
  28. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement