2 * Sample server implementation using SWIFT library
8 #include <netinet/in.h>
10 #include <sys/socket.h>
13 #include "lib_swift.h"
17 Swift s = socketSwift(1);
18 struct sockSwiftaddr my_addr, from;
21 struct listsockaddr lsa;
24 // populate sockSwiftaddr
25 my_addr.sin_family = AF_INET;
26 my_addr.sin_port = htons(SWIFT_PORT);
27 my_addr.sin_addr.N = 1;
28 my_addr.sin_addr.s_addr[0] = htonl(INADDR_ANY);
30 //recvfromSwift(s, buf, 100, 0, (struct sockaddr *)&si_other, &slen);
32 bindSwift(s, &my_addr, sizeof(my_addr));
33 len = listenfromSwift(s, buf, 100, 0, &from, &slen);
34 transformFromSwiftToAddr(&lsa, from);
35 printf("Received packet from %s:%d with data: %s %d\n", inet_ntoa(lsa.sa[0].sin_addr), ntohs(lsa.sa[0].sin_port), buf, (int)len);
37 sendToSwift(s, buf, len, 0, &from, slen);