libdill: Structured Concurrency for C

NAME

pfx_attach - creates PFX protocol on top of underlying socket

SYNOPSIS

#include <libdill.h>

int pfx_attach(int s);

DESCRIPTION

PFX is a message-based protocol to send binary messages prefixed by 8-byte size in network byte order. The protocol has no initial handshake. Terminal handshake is accomplished by each peer sending eight 0xFF bytes.

This function instantiates PFX protocol on top of underlying bytestream protocol s.

The socket can be cleanly shut down using pfx_detach() function.

RETURN VALUE

Newly created socket handle. On error, it returns -1 and sets errno to one of the values below.

ERRORS

EXAMPLE

int u = tcp_connect(&addr, -1);
int s = pfx_attach(u);