Tor  0.4.7.0-alpha-dev
Functions
buffers_net.h File Reference

Header file for buffers_net.c. More...

#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)
 
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)
 

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 
)

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 249 of file buffers_net.c.

◆ buf_flush_to_socket()

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

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 224 of file buffers_net.c.

◆ 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 260 of file buffers_net.c.

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 235 of file buffers_net.c.