tor  0.4.1.0-alpha-dev
Functions
buffers_net.h File Reference
#include <stddef.h>
#include "lib/net/socket.h"

Go to the source code of this file.

Functions

int buf_read_from_socket (struct buf_t *buf, tor_socket_t s, size_t at_most, int *reached_eof, int *socket_error)
 
int buf_flush_to_socket (struct buf_t *buf, tor_socket_t s, size_t sz, size_t *buf_flushlen)
 
int buf_read_from_pipe (struct buf_t *buf, int fd, size_t at_most, int *reached_eof, int *socket_error)
 
int buf_flush_to_pipe (struct buf_t *buf, int fd, size_t sz, size_t *buf_flushlen)
 

Detailed Description

Header file for buffers_net.c.

Definition in file buffers_net.h.

Function Documentation

◆ buf_flush_to_pipe()

int buf_flush_to_pipe ( buf_t *  buf,
int  fd,
size_t  sz,
size_t *  buf_flushlen 
)

Write data from buf to the pipe fd. Write at most sz bytes, decrement *buf_flushlen by the number of bytes actually written, and remove the written bytes from the buffer. Return the number of bytes written on success, -1 on failure. Return 0 if write() would block.

Definition at line 257 of file buffers_net.c.

References buf_flush_to_fd().

◆ buf_flush_to_socket()

int buf_flush_to_socket ( buf_t *  buf,
tor_socket_t  s,
size_t  sz,
size_t *  buf_flushlen 
)

Write data from buf to the socket s. Write at most sz bytes, decrement *buf_flushlen by the number of bytes actually written, and remove the written bytes from the buffer. Return the number of bytes written on success, -1 on failure. Return 0 if write() would block.

Definition at line 231 of file buffers_net.c.

References buf_flush_to_fd().

◆ buf_read_from_pipe()

int buf_read_from_pipe ( buf_t *  buf,
int  fd,
size_t  at_most,
int *  reached_eof,
int *  socket_error 
)

Read from pipe fd, writing onto end of buf. Read at most at_most bytes, growing the buffer as necessary. If read() returns 0 (because of EOF), set *reached_eof to 1 and return 0. Return -1 on error; else return the number of bytes read.

Definition at line 269 of file buffers_net.c.

References buf_read_from_fd().

Referenced by process_unix_read_handle().

◆ buf_read_from_socket()

int buf_read_from_socket ( buf_t *  buf,
tor_socket_t  s,
size_t  at_most,
int *  reached_eof,
int *  socket_error 
)

Read from socket s, writing onto end of buf. Read at most at_most bytes, growing the buffer as necessary. If recv() returns 0 (because of EOF), set *reached_eof to 1 and return 0. Return -1 on error; else return the number of bytes read.

Definition at line 243 of file buffers_net.c.

References buf_read_from_fd().