SCTC
the soundcloud.com terminal client
Data Structures | Macros | Functions
plain.c File Reference
#include "../log.h"
#include "../helper.h"
#include "plain.h"
#include "network.h"
Include dependency graph for plain.c:

Data Structures

struct  plain_conn
 

Macros

#define PLAIN_CONN_MAGIC   0x35363738
 

Functions

bool plain_send (struct network_conn *nwc, char *buffer, size_t buffer_len)
 
bool plain_send_fmt (struct network_conn *nwc, char *fmt,...)
 
int plain_recv (struct network_conn *nwc, char *buffer, size_t buffer_len)
 Receive a data from a connected plain TCP/IP socket. More...
 
int plain_recv_byte (struct network_conn *nwc)
 Receive a single byte from a connected plain TCP/IP socket. More...
 
void plain_disconnect (struct network_conn *nwc)
 Disconnect a connected plain TCP/IP socket. More...
 
struct network_connplain_connect (char *server, int port)
 Connect a plain TCP/IP socket to server:port. More...
 

Macro Definition Documentation

#define PLAIN_CONN_MAGIC   0x35363738

Function Documentation

struct network_conn* plain_connect ( char *  server,
int  port 
)

Connect a plain TCP/IP socket to server:port.

Parameters
serverThe server to connect to, either an IP or a hostname.
portThe servers port ( $ 0 \le port \le 65536 $)
Returns
Pointer to a network_conn struct, or NULL in case of an error

Here is the call graph for this function:

Here is the caller graph for this function:

void plain_disconnect ( struct network_conn nwc)

Disconnect a connected plain TCP/IP socket.

After a call to plain_disconnect() all the memory assocatied to nwc is free'd, nwc may not be used anymore.

Parameters
nwcThe connection to disconnect

Here is the caller graph for this function:

int plain_recv ( struct network_conn nwc,
char *  buffer,
size_t  buffer_len 
)

Receive a data from a connected plain TCP/IP socket.

TODO

Parameters
nwcThe connection to read from
bufferThe buffer receiving the read data
buffer_lenThe size of the buffer
Returns
The byte or -1 on EOF

Here is the caller graph for this function:

int plain_recv_byte ( struct network_conn nwc)

Receive a single byte from a connected plain TCP/IP socket.

As soon as -1 is returned the underlying TCP/IP connection has been disconnected (for instance by the remote server). Any further call to plain_recv* will fail, so just call plain_disconnect() to free the data. "The horse is dead"

Parameters
nwcThe connection to read from
Returns
The byte or -1 on EOF

Here is the caller graph for this function:

bool plain_send ( struct network_conn nwc,
char *  buffer,
size_t  buffer_len 
)

Here is the caller graph for this function:

bool plain_send_fmt ( struct network_conn nwc,
char *  fmt,
  ... 
)

Here is the caller graph for this function: