Skip to content

Instantly share code, notes, and snippets.

@cwilhit
Last active March 15, 2018 02:22
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save cwilhit/a82f786770839a9f3e8e31e93ff2f84e to your computer and use it in GitHub Desktop.
Save cwilhit/a82f786770839a9f3e8e31e93ff2f84e to your computer and use it in GitHub Desktop.
// Create a server AF_UNIX socket
#define SERVER_ADDRESS “c:\unix\server.sock”
SOCKADDR_UN ServerAddress = {0};
Server = socket(AF_UNIX, SOCK_STREAM, 0);
// Bind the socket to a path.
ServerAddress.sun_family = AF_UNIX;
strcpy(ServerAddress.sun_path, SERVER_ADDRESS);
bind(Server, &ServerAddress, sizeof(ServerAddress));
// Accept a connection.
listen(Server, 5);
Accepted = accept(Server, ….);
// Send and receive data on the accepted socket.
// Shutdown and close the connection.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment