YAZ  5.23.1
Data Structures | Macros | Functions
spipe.c File Reference

Implements socket-pipes. More...

#include <assert.h>
#include <stdlib.h>
#include <string.h>
#include <errno.h>
#include <yaz/xmalloc.h>
#include <yaz/nmem.h>
#include <yaz/log.h>
#include <yaz/spipe.h>
#include <fcntl.h>

Go to the source code of this file.

Data Structures

struct  yaz_spipe
 

Macros

#define YAZ_INVALID_SOCKET   -1
 
#define YAZ_SOCKLEN_T   int
 

Functions

static void yaz_spipe_close (int *fd)
 
static int nonblock (int s)
 
yaz_spipe_t yaz_spipe_create (int port_to_use, WRBUF *err_msg)
 create socket pipe More...
 
void yaz_spipe_destroy (yaz_spipe_t p)
 destroys socket pipe More...
 
int yaz_spipe_get_read_fd (yaz_spipe_t p)
 returns reading socket More...
 
int yaz_spipe_get_write_fd (yaz_spipe_t p)
 returns writing socket More...
 

Detailed Description

Implements socket-pipes.

Definition in file spipe.c.

Macro Definition Documentation

#define YAZ_INVALID_SOCKET   -1

Definition at line 32 of file spipe.c.

Referenced by yaz_spipe_close(), and yaz_spipe_create().

#define YAZ_SOCKLEN_T   int

Definition at line 66 of file spipe.c.

Referenced by yaz_spipe_create().

Function Documentation

static int nonblock ( int  s)
static

Definition at line 86 of file spipe.c.

Referenced by yaz_spipe_create().

static void yaz_spipe_close ( int *  fd)
static

Definition at line 74 of file spipe.c.

References YAZ_INVALID_SOCKET.

Referenced by yaz_spipe_create(), and yaz_spipe_destroy().

yaz_spipe_t yaz_spipe_create ( int  port_to_use,
WRBUF err_msg 
)

create socket pipe

Parameters
port_to_useport that we temporarily bind to
err_msgerror message reference (0 if not to be set)
Returns
0 on failure; != 0 on success

Definition at line 99 of file spipe.c.

References yaz_spipe::m_fd, yaz_spipe::m_socket, nonblock(), wrbuf_printf(), xfree, xmalloc, YAZ_INVALID_SOCKET, YAZ_SOCKLEN_T, yaz_spipe_close(), and yaz_spipe_destroy().

void yaz_spipe_destroy ( yaz_spipe_t  p)

destroys socket pipe

Parameters
psocket pipe pointer

Definition at line 253 of file spipe.c.

References yaz_spipe::m_fd, yaz_spipe::m_socket, xfree, and yaz_spipe_close().

Referenced by yaz_spipe_create().

int yaz_spipe_get_read_fd ( yaz_spipe_t  p)

returns reading socket

Parameters
psocket pipe pointer

Definition at line 264 of file spipe.c.

References yaz_spipe::m_fd.

int yaz_spipe_get_write_fd ( yaz_spipe_t  p)

returns writing socket

Parameters
psocket pipe pointer

Definition at line 269 of file spipe.c.

References yaz_spipe::m_fd.