BRL-CAD
client.c File Reference
#include "common.h"
#include <stdlib.h>
#include <signal.h>
#include <string.h>
#include <stdio.h>
#include "bio.h"
#include "bu/log.h"
#include "bu/malloc.h"
#include "bu/getopt.h"
#include "bu/file.h"
#include "pkg.h"
#include "ntp.h"
Include dependency graph for client.c:

Go to the source code of this file.

Data Structures

struct  _my_data_
 

Typedefs

typedef struct _my_data_ my_data
 

Functions

void server_helo (struct pkg_conn *connection, char *buf)
 
void server_data (struct pkg_conn *connection, char *buf)
 
void server_ciao (struct pkg_conn *connection, char *buf)
 
void run_client (const char *server, int port, const char *file)
 
int main (int argc, char *argv[])
 

Detailed Description

Relatively simple example file transfer program using libpkg, written in a ttcp style.

Definition in file client.c.

Typedef Documentation

typedef struct _my_data_ my_data

Function Documentation

void server_helo ( struct pkg_conn connection,
char *  buf 
)

callback when a HELO message packet is received.

We should not encounter this packet specifically since we listened for it before beginning processing of packets as part of a simple handshake setup.

Definition at line 88 of file client.c.

References bu_log().

Referenced by run_client().

Here is the call graph for this function:

void server_data ( struct pkg_conn connection,
char *  buf 
)

callback when a DATA message packet is received

Definition at line 99 of file client.c.

References bu_log().

Referenced by run_client().

Here is the call graph for this function:

void server_ciao ( struct pkg_conn connection,
char *  buf 
)

callback when a CIAO message packet is received

Definition at line 110 of file client.c.

References bu_log().

Referenced by run_client().

Here is the call graph for this function:

void run_client ( const char *  server,
int  port,
const char *  file 
)

start up a client that connects to the given server, and sends serialized file data.

our callbacks for each message type

Definition at line 122 of file client.c.

References bu_bomb(), bu_calloc(), bu_free(), bu_log(), _my_data_::connection, MAGIC_ID, MAX_DIGITS, MSG_CIAO, MSG_DATA, MSG_HELO, PKC_ERROR, pkg_conn::pkc_inbuf, pkg_conn::pkc_switch, pkg_conn::pkc_type, pkg_close(), pkg_open(), pkg_process(), pkg_send(), pkg_suckin(), _my_data_::port, _my_data_::server, server_ciao(), server_data(), and server_helo().

Referenced by main().

Here is the call graph for this function:

int main ( int  argc,
char *  argv[] 
)

main application for both the client and server

Definition at line 225 of file client.c.

References bu_file_exists(), bu_getopt(), bu_log(), bu_optarg, bu_optind, bu_optopt, and run_client().

Here is the call graph for this function: