Low-level socket handling. More...
#include "config.h"
#include <errno.h>
#include <stdbool.h>
#include <string.h>
#include <time.h>
#include "private.h"
#include "mutt/lib.h"
#include "config/lib.h"
#include "core/lib.h"
#include "socket.h"
#include "connaccount.h"
#include "connection.h"
#include "protos.h"
#include "ssl.h"
Go to the source code of this file.
Functions | |
static int | socket_preconnect (void) |
Execute a command before opening a socket. | |
int | mutt_socket_open (struct Connection *conn) |
Simple wrapper. | |
int | mutt_socket_close (struct Connection *conn) |
Close a socket. | |
int | mutt_socket_read (struct Connection *conn, char *buf, size_t len) |
Read from a Connection. | |
int | mutt_socket_write_d (struct Connection *conn, const char *buf, int len, int dbg) |
Write data to a socket. | |
int | mutt_socket_poll (struct Connection *conn, time_t wait_secs) |
Checks whether reads would block. | |
int | mutt_socket_readchar (struct Connection *conn, char *c) |
Simple read buffering to speed things up. | |
int | mutt_socket_readln_d (char *buf, size_t buflen, struct Connection *conn, int dbg) |
Read a line from a socket. | |
struct Connection * | mutt_socket_new (enum ConnectionType type) |
Allocate and initialise a new connection. | |
void | mutt_socket_empty (struct Connection *conn) |
Clear out any queued data. | |
int | mutt_socket_buffer_readln_d (struct Buffer *buf, struct Connection *conn, int dbg) |
Read a line from a socket into a Buffer. | |
Low-level socket handling.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/.
Definition in file socket.c.
|
static |
Execute a command before opening a socket.
0 | Success |
>0 | An errno, e.g. EPERM |
Definition at line 50 of file socket.c.
int mutt_socket_open | ( | struct Connection * | conn | ) |
Simple wrapper.
conn | Connection to a server |
0 | Success |
-1 | Error |
Definition at line 76 of file socket.c.
int mutt_socket_close | ( | struct Connection * | conn | ) |
Close a socket.
conn | Connection to a server |
0 | Success |
-1 | Error |
Definition at line 100 of file socket.c.
int mutt_socket_read | ( | struct Connection * | conn, |
char * | buf, | ||
size_t | len | ||
) |
Read from a Connection.
conn | Connection a server |
buf | Buffer to store read data |
len | length of the buffer |
>0 | Success, number of bytes read |
-1 | Error, see errno |
Definition at line 128 of file socket.c.
int mutt_socket_write_d | ( | struct Connection * | conn, |
const char * | buf, | ||
int | len, | ||
int | dbg | ||
) |
Write data to a socket.
conn | Connection to a server |
buf | Buffer with data to write |
len | Length of data to write |
dbg | Debug level for logging |
>0 | Number of bytes written |
-1 | Error |
Definition at line 142 of file socket.c.
int mutt_socket_poll | ( | struct Connection * | conn, |
time_t | wait_secs | ||
) |
Checks whether reads would block.
conn | Connection to a server |
wait_secs | How long to wait for a response |
>0 | There is data to read |
0 | Read would block |
-1 | Connection doesn't support polling |
Definition at line 182 of file socket.c.
int mutt_socket_readchar | ( | struct Connection * | conn, |
char * | c | ||
) |
Simple read buffering to speed things up.
[in] | conn | Connection to a server |
[out] | c | Character that was read |
1 | Success |
-1 | Error |
Definition at line 200 of file socket.c.
int mutt_socket_readln_d | ( | char * | buf, |
size_t | buflen, | ||
struct Connection * | conn, | ||
int | dbg | ||
) |
Read a line from a socket.
buf | Buffer to store the line |
buflen | Length of data to write |
conn | Connection to a server |
dbg | Debug level for logging |
>0 | Success, number of bytes read |
-1 | Error |
Definition at line 238 of file socket.c.
struct Connection * mutt_socket_new | ( | enum ConnectionType | type | ) |
Allocate and initialise a new connection.
type | Type of the new Connection |
ptr | New Connection |
Definition at line 272 of file socket.c.
void mutt_socket_empty | ( | struct Connection * | conn | ) |
Clear out any queued data.
conn | Connection to a server |
The internal buffer is emptied and any data that has already arrived at this machine (in kernel buffers) is read and dropped.
Definition at line 306 of file socket.c.
int mutt_socket_buffer_readln_d | ( | struct Buffer * | buf, |
struct Connection * | conn, | ||
int | dbg | ||
) |
Read a line from a socket into a Buffer.
buf | Buffer to store the line |
conn | Connection to a server |
dbg | Debug level for logging |
>0 | Success, number of bytes read |
-1 | Error |
Definition at line 328 of file socket.c.