4 #define SWIFT_PORT 8080
5 #define PACKET_SIZE 4*1024
10 printf("%s:%d: ", __func__, __LINE__); \
18 printf("%s:%d: ", __func__, __LINE__); \
25 #define Dprintf(msg,...) printf("[%s]:%d" msg, __FILE__, __LINE__, ##__VA_ARGS__)
27 #define Dprintf(msg,...) /* do nothing */
31 typedef struct swift {
32 int socketListener, socketData;
33 struct sockaddr_in socketListenerAddr;
36 // swift_addr structure similar with in_addr
38 unsigned short N; // e.g. number of s_addr
39 unsigned long s_addr[MAX_IPs]; // i.p. ip list
42 // swift struct similar with sock_addr
43 typedef struct sockSwiftaddr {
44 short sin_family; // e.g. AF_INET
45 unsigned short sin_port; // e.g. htons(3490)
46 struct swift_addr sin_addr; // see struct swift_addr, below
52 struct sockaddr_in sa[MAX_IPs];
55 // Function to create a Swift socket
58 // Function to close a Swift socket
59 void closeSwift(Swift);
61 // Function to listen to a port
62 int listenfromSwift (Swift s, void *buf, size_t len, int flags,
63 struct sockSwiftaddr * __restrict__ from, socklen_t *fromlen);
65 // Function to bind a port for swift socket
66 int bindSwift(Swift s, const struct sockSwiftaddr *my_addr, socklen_t addrlen);
68 // Function to receive a message
69 ssize_t recvfrom(Swift s, void *buf, size_t len, int flags,
70 struct sockSwiftaddr *from, socklen_t *fromlen);
72 // Function to send a message
73 ssize_t sendto(Swift s, const void *buf, size_t len, int flags,
74 const struct sockSwiftaddr *to, socklen_t tolen);