Last active
November 6, 2017 13:11
-
-
Save tevino/bfb49384c54e7a41ee16a6a9864210f7 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
#include <stdlib.h> | |
#include <sys/types.h> | |
#include <sys/socket.h> | |
int main(){ | |
int fds[2]; | |
int ret; | |
ssize_t size; | |
ret = socketpair(AF_UNIX, SOCK_STREAM, 0, fds); | |
if (ret != 0) { | |
printf("Error %d", ret); | |
return ret; | |
} | |
printf("Sending 'Hello'\n"); | |
size = send(fds[0], "Hello", 5, 0); | |
printf("sent: %zd\n", size); | |
char* buffer = malloc(sizeof(char) * 10); | |
size = recv(fds[1], buffer, sizeof(buffer), 0); | |
printf("recv[%zd]: %s\n", size, buffer); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment