io.h File Reference
`#include <proton/import_export.h>`
`#include <proton/error.h>`
`#include <proton/type_compat.h>`
`#include <stddef.h>`

Go to the source code of this file.

## Macros

#define | PN_INVALID_SOCKET (-1)

## Typedefs

typedef int | pn_socket_t
| A pn_socket_t provides an abstract handle to an IO stream. More...
typedef struct pn_io_t | pn_io_t
| A pn_io_t manages IO for a group of pn_socket_t handles. More...
typedef struct pn_selector_t | pn_selector_t
| A pn_selector_t provides a selection mechanism that allows efficient monitoring of a large number of Proton connections and listeners. More...

## Functions

PN_EXTERN pn_io_t * | pn_io (void)
PN_EXTERN void | pn_io_free (pn_io_t *io)
PN_EXTERN pn_error_t * | pn_io_error (pn_io_t *io)
PN_EXTERN pn_socket_t | pn_connect (pn_io_t *io, const char *host, const char *port)
PN_EXTERN pn_socket_t | pn_listen (pn_io_t *io, const char *host, const char *port)
PN_EXTERN pn_socket_t | pn_accept (pn_io_t *io, pn_socket_t socket, char *name, size_t size)
PN_EXTERN void | pn_close (pn_io_t *io, pn_socket_t socket)
PN_EXTERN ssize_t | pn_send (pn_io_t *io, pn_socket_t socket, const void *buf, size_t size)
PN_EXTERN ssize_t | pn_recv (pn_io_t *io, pn_socket_t socket, void *buf, size_t size)
PN_EXTERN int | pn_pipe (pn_io_t *io, pn_socket_t *dest)
PN_EXTERN ssize_t | pn_read (pn_io_t *io, pn_socket_t socket, void *buf, size_t size)
PN_EXTERN ssize_t | pn_write (pn_io_t *io, pn_socket_t socket, const void *buf, size_t size)
PN_EXTERN bool | pn_wouldblock (pn_io_t *io)
PN_EXTERN pn_selector_t * | pn_io_selector (pn_io_t *io)

## Macro Definition Documentation

## PN_INVALID_SOCKET

#define PN_INVALID_SOCKET (-1)

## Typedef Documentation

## pn_io_t

typedef struct pn_io_t pn_io_t

A pn_io_t manages IO for a group of pn_socket_t handles.

A pn_io_t object may have zero or one pn_selector_t selectors associated with it (see pn_io_selector()). If one is associated, all the pn_socket_t handles managed by a pn_io_t must use that pn_selector_t instance.

The pn_io_t interface is single-threaded. All methods are intended to be used by one thread at a time, except that multiple threads may use:

pn_write() pn_send() pn_recv() pn_close() pn_selector_select()

provided at most one thread is calling pn_selector_select() and the other threads are operating on separate pn_socket_t handles.

## pn_selector_t

typedef struct pn_selector_t pn_selector_t

A pn_selector_t provides a selection mechanism that allows efficient monitoring of a large number of Proton connections and listeners.

External (non-Proton) sockets may also be monitored, either solely for event notification (read, write, and timer) or event notification and use with pn_io_t interfaces.

## pn_socket_t

typedef int pn_socket_t

A pn_socket_t provides an abstract handle to an IO stream.

The pipe version is uni-directional. The network socket version is bi-directional. Both are non-blocking.

pn_socket_t handles from pn_pipe() may only be used with pn_read(), pn_write(), pn_close() and pn_selector_select().

pn_socket_t handles from pn_listen(), pn_accept() and pn_connect() must perform further IO using Proton functions. Mixing Proton io.h functions with native IO functions on the same handles will result in undefined behavior.

pn_socket_t handles may only be used with a single pn_io_t during their lifetime.

## Function Documentation

## pn_accept()

PN_EXTERN pn_socket_t pn_accept | ( | pn_io_t * | io,
|  | pn_socket_t | socket,
|  | char * | name,
|  | size_t | size
| ) |  |

## pn_close()

PN_EXTERN void pn_close | ( | pn_io_t * | io,
|  | pn_socket_t | socket
| ) |  |

## pn_connect()

PN_EXTERN pn_socket_t pn_connect | ( | pn_io_t * | io,
|  | const char * | host,
|  | const char * | port
| ) |  |

## pn_io()

PN_EXTERN pn_io_t* pn_io | ( | void |  | ) |

## pn_io_error()

PN_EXTERN pn_error_t* pn_io_error | ( | pn_io_t * | io | ) |

## pn_io_free()

PN_EXTERN void pn_io_free | ( | pn_io_t * | io | ) |

## pn_io_selector()

PN_EXTERN pn_selector_t* pn_io_selector | ( | pn_io_t * | io | ) |

## pn_listen()

PN_EXTERN pn_socket_t pn_listen | ( | pn_io_t * | io,
|  | const char * | host,
|  | const char * | port
| ) |  |

## pn_pipe()

PN_EXTERN int pn_pipe | ( | pn_io_t * | io,
|  | pn_socket_t * | dest
| ) |  |

## pn_read()

PN_EXTERN ssize_t pn_read | ( | pn_io_t * | io,
|  | pn_socket_t | socket,
|  | void * | buf,
|  | size_t | size
| ) |  |

## pn_recv()

PN_EXTERN ssize_t pn_recv | ( | pn_io_t * | io,
|  | pn_socket_t | socket,
|  | void * | buf,
|  | size_t | size
| ) |  |

## pn_send()

PN_EXTERN ssize_t pn_send | ( | pn_io_t * | io,
|  | pn_socket_t | socket,
|  | const void * | buf,
|  | size_t | size
| ) |  |

## pn_wouldblock()

PN_EXTERN bool pn_wouldblock | ( | pn_io_t * | io | ) |

## pn_write()

PN_EXTERN ssize_t pn_write | ( | pn_io_t * | io,
|  | pn_socket_t | socket,
|  | const void * | buf,
|  | size_t | size
| ) |  |