Nilorea Library
C utilities for networking, threading, graphics
Loading...
Searching...
No Matches
ex_accept_pool_client.c File Reference
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <errno.h>
#include <getopt.h>
#include <signal.h>
#include "nilorea/n_common.h"
#include "nilorea/n_log.h"
#include "nilorea/n_network.h"
#include "nilorea/n_network_msg.h"
#include "nilorea/n_thread_pool.h"
+ Include dependency graph for ex_accept_pool_client.c:

Go to the source code of this file.

Data Structures

struct  CLIENT_STATE
 shared state for client threads More...
 

Macros

#define NETMSG_DATA   1
 type of data message
 

Functions

static void * client_worker_echo (void *ptr)
 Echo mode: connect, send a message, receive echo, close.
 
static void * client_worker_fast (void *ptr)
 Fast mode: connect and immediately close (measures pure accept throughput)
 
int main (int argc, char **argv)
 
static void usage (void)
 

Variables

static int client_echo_mode = 0
 

Data Structure Documentation

◆ CLIENT_STATE

struct CLIENT_STATE

shared state for client threads

Examples
ex_accept_pool_client.c.

Definition at line 53 of file ex_accept_pool_client.c.

+ Collaboration diagram for CLIENT_STATE:
Data Fields
size_t fail_count atomic counter of failed connections
char * host server host
pthread_mutex_t lock mutex for counters
char * port server port
size_t success_count atomic counter of successful connections

Macro Definition Documentation

◆ NETMSG_DATA

#define NETMSG_DATA   1

type of data message

Examples
ex_accept_pool_client.c, and ex_network.h.

Definition at line 48 of file ex_accept_pool_client.c.

Function Documentation

◆ client_worker_echo()

static void * client_worker_echo ( void *  ptr)
static

Echo mode: connect, send a message, receive echo, close.

Parameters
ptrpointer to CLIENT_STATE
Returns
NULL
Examples
ex_accept_pool_client.c.

Definition at line 96 of file ex_accept_pool_client.c.

References __n_assert, add_int_to_msg(), add_nstrptr_to_msg(), char_to_nstr(), create_msg(), delete_msg(), CLIENT_STATE::fail_count, free_nstr, CLIENT_STATE::host, CLIENT_STATE::lock, LOG_DEBUG, make_str_from_msg(), n_log, NETMSG_DATA, netw, netw_add_msg(), netw_close(), netw_connect(), netw_start_thr_engine(), netw_wait_msg(), NETWORK_IPALL, CLIENT_STATE::port, and CLIENT_STATE::success_count.

Referenced by main().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ client_worker_fast()

static void * client_worker_fast ( void *  ptr)
static

Fast mode: connect and immediately close (measures pure accept throughput)

Parameters
ptrpointer to CLIENT_STATE
Returns
NULL
Examples
ex_accept_pool_client.c.

Definition at line 71 of file ex_accept_pool_client.c.

References __n_assert, CLIENT_STATE::fail_count, CLIENT_STATE::host, CLIENT_STATE::lock, netw, netw_close(), netw_connect(), NETWORK_IPALL, CLIENT_STATE::port, and CLIENT_STATE::success_count.

Referenced by main().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ main()

◆ usage()

Variable Documentation

◆ client_echo_mode

int client_echo_mode = 0
static
Examples
ex_accept_pool_client.c.

Definition at line 50 of file ex_accept_pool_client.c.

Referenced by main().