Kaya 0.4.4 reference for Sockets::socketPair

List of functions and data types in Sockets

Pair<Socket, Socket> socketPair()

Usage

This function creates a pair of sockets that can be used for bi-directional communication. The most common use of this is for setting up communications between a process and its Posix::fork()ed child - each process closes one of the sockets after the fork.

sockets = socketPair();
pid = fork();
if (pid == 0) {
// child process
  close(sockets.fst);
  // do something
} else {
  close(sockets.snd);
  // do something else
}

Related

kaya@kayalang.org | Last modified 29 November 2011 | Supported by Durham CompSoc | Powered by Kaya