libmctProgrammer’s Manual



mct_bridge — Create an MCT session


#include <sys/types.h>
#include <sys/socket.h>

#include <mct/session.h>

mct_bridge(struct mct *mct, int type,
	const struct sockaddr *src, socklen_t srclen,
	const struct sockaddr *dst, socklen_t dstlen);


The mct_bridge() function issues a request for mctd to create a new session bound to a source address, src and connected to a destination address, dst.

dst and src are required to be of the same address family and protocol.

For connectionless protocols the addresses are bridged such that data arriving at src is duplicated onto dst.

For connection orientated protocols the addresses are bridged such that src is placed into a listening state, and a new session is created for each connection then made to src. Data arriving at the src end of this new session is then duplicated to dst and vice-versa.

Return Value

The mct_bridge() function returns a valid session ID >=0 on success. On failure this function returns -1 and errno is set accordingly.


The mct_bridge() function may fail for any of the reasons malloc or the socket API produce.

In addition, mct_bridge() may fail for any of the reasons documented by mct_ipc.

In addition, mct_bridge() may fail for the following reasons:


An invalid session ID was returned by mctd.


An unsupported address family was given. See caveats below.


Currently the only address families supported for bridging are AF_INET and AF_INET6.

The backlog for the listen queue of connection orientated sessions is fixed.

See Also

mctd, mct, mct_ipc, mct_session_close, bind, listen, connect.