diff --git a/examples/interop_pseudo_socket/main.c b/examples/interop_pseudo_socket/main.c new file mode 100644 index 0000000000000000000000000000000000000000..183e5e816c2d8d786f6f00e77013e7a2e91d7205 --- /dev/null +++ b/examples/interop_pseudo_socket/main.c @@ -0,0 +1,23 @@ +#include // socket addresses, constants +#include +#include "pseudo_socket.h" +#define BUFSIZE 512 +int main() { + // --- setup --- + struct sockaddr_in local, peer; + /* (address structure initializations omitted) */ + int fd = rw_socket(AF_INET, SOCK_DGRAM, 0); + rw_bind(fd, (const struct sockaddr *)&local, sizeof(local)); + rw_connect(fd, (const struct sockaddr *)&peer, sizeof(peer)); + // --- communication --- + char buffer = malloc(BUFSIZE); + size_t msglen, i; + msglen = rw_recv(fd, (const void *)buffer, BUFSIZE, 0); + for(i=0; i