bsd style socket handling...
authorMarkus Bröker <mbroeker@largo.dyndns.tv>
Fri, 05 Mar 2010 22:02:56 +0100
changeset 111 2247473fd12d
parent 110 e1bc09732fa3
child 112 9bfb339a8156
bsd style socket handling... committer: Markus Bröker <mbroeker@largo.homelinux.org>
connection.c
--- a/connection.c
+++ b/connection.c
@@ -12,6 +12,10 @@
 #include <netdb.h>
 #include <arpa/inet.h>
 
+#include <netinet/in.h>
+#include <sys/types.h>
+#include <sys/socket.h>
+
 int connection (char *ip, unsigned short port)
 {
     struct hostent *hs;
@@ -20,7 +24,7 @@
     int sockfd;
 
     memset (&sock, 0, sizeof (sock));
-    sock.sin_family = AF_INET;
+    sock.sin_family = PF_INET;
     sock.sin_port = htons (port);
 
     if ((sock.sin_addr.s_addr = inet_addr (ip)) == -1) {
@@ -32,7 +36,7 @@
         memcpy (&sock.sin_addr.s_addr, hs->h_addr_list[0], hs->h_length);
     }
 
-    if ((sockfd = socket (AF_INET, SOCK_STREAM, 0)) < 0) {
+    if ((sockfd = socket (PF_INET, SOCK_STREAM, 0)) < 0) {
         perror ("[-] Error");
         return -1;
     }