Update:
[swifty.git] / src / client.c
1 #include <stdio.h>
2 #include <stdlib.h>
3 #include <arpa/inet.h>
4 #include <netinet/in.h>
5 #include <sys/types.h>
6 #include <sys/socket.h>
7 #include <unistd.h>
8
9 #include "lib_swift.h"
10
11 int main()
12 {
13         Swift s = socketSwift(1);
14         struct sockSwiftaddr my_addr;
15         char buf[100];
16         
17         // populate sockSwiftaddr
18         my_addr.sin_family = AF_INET;
19         my_addr.sin_port = htons(SWIFT_PORT);
20         my_addr.sin_addr.N = 1; 
21         my_addr.sin_addr.s_addr[0] = htonl(INADDR_LOOPBACK);    
22         
23         recvfromSwift(s, buf, 100, 0, &my_addr, sizeof(my_addr));
24         
25         struct listsockaddr lsa =  transformFromSwiftToAddr(my_addr);
26         printf("Received packet from %s:%d\nData: %s\n\n", inet_ntoa(lsa.sa[0].sin_addr), ntohs(my_addr.sin_port), buf);
27         
28         closeSwift(s);
29         return 0;       
30 }