1 This is the swift structures:
4 int socketListener, socketData;
5 struct sockaddr_in socketListenerAddr;
8 // swift_addr structure similar with in_addr
10 unsigned short N; // e.g. number of s_addr
11 unsigned long s_addr[MAX_IPs]; // i.p. ip list
14 // swift struct similar with sock_addr
15 typedef struct sockSwiftaddr {
16 short sin_family; // e.g. AF_INET
17 unsigned short sin_port; // e.g. htons(3490)
18 struct swift_addr sin_addr; // see struct swift_addr, below
24 struct sockaddr_in sa[MAX_IPs];
27 With this new structures we modify the normal socket api and the new api is:
29 // Function to create a Swift socket
32 // Function to close a Swift socket
33 void closeSwift(Swift);
35 // Function to listen to a port
36 int listenfromSwift (Swift s, void *buf, size_t len, int flags,
37 struct sockSwiftaddr * __restrict__ from, socklen_t *fromlen);
39 // Function to bind a port for swift socket
40 int bindSwift(Swift s, const struct sockSwiftaddr *my_addr, socklen_t addrlen);
42 // Function to receive a message
43 ssize_t recvFromSwift(Swift s, void *buf, size_t len, int flags,
44 struct sockSwiftaddr *from, socklen_t *fromlen);
46 // Function to send a message
47 ssize_t sendToSwift(Swift s, const void *buf, size_t len, int flags,
48 const struct sockSwiftaddr *to, socklen_t tolen);