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

Go to the source code of this file.

Macros

#define MODE_CLIENT   1
#define MODE_SERVER   0
#define MSG_RESP   "RESP"
 sync response message: "RESP client_send_time server_time\n"
#define MSG_SYNC   "SYNC"
 sync request message: "SYNC client_send_time\n"

Functions

static double get_time (void)
int main (int argc, char *argv[])
static void run_client (char *server, char *port, int nb_rounds)
static void run_server (char *port, double fake_offset, int nb_rounds)
static void usage (const char *prog)

Macro Definition Documentation

◆ MODE_CLIENT

#define MODE_CLIENT   1
Examples
ex_clock_sync.c, and ex_network_reactor.c.

Definition at line 54 of file ex_clock_sync.c.

Referenced by main(), and main().

◆ MODE_SERVER

#define MODE_SERVER   0
Examples
ex_clock_sync.c, and ex_network_reactor.c.

Definition at line 53 of file ex_clock_sync.c.

Referenced by main(), and main().

◆ MSG_RESP

#define MSG_RESP   "RESP"

sync response message: "RESP client_send_time server_time\n"

Examples
ex_clock_sync.c.

Definition at line 59 of file ex_clock_sync.c.

Referenced by run_client(), and run_server().

◆ MSG_SYNC

#define MSG_SYNC   "SYNC"

sync request message: "SYNC client_send_time\n"

Examples
ex_clock_sync.c.

Definition at line 57 of file ex_clock_sync.c.

Referenced by run_client(), and run_server().

Function Documentation

◆ get_time()

double get_time ( void )
static
Examples
ex_clock_sync.c.

Definition at line 77 of file ex_clock_sync.c.

Referenced by run_client(), and run_server().

Here is the caller graph for this function:

◆ main()

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

Definition at line 231 of file ex_clock_sync.c.

References FreeNoLog, getoptret, LOG_DEBUG, LOG_ERR, LOG_INFO, log_level, LOG_NOTICE, mode, MODE_CLIENT, MODE_SERVER, port, run_client(), run_server(), server, set_log_level(), and usage().

Here is the call graph for this function:

◆ run_client()

void run_client ( char * server,
char * port,
int nb_rounds )
static

◆ run_server()

void run_server ( char * port,
double fake_offset,
int nb_rounds )
static
Examples
ex_clock_sync.c, and ex_network_reactor.c.

Definition at line 83 of file ex_clock_sync.c.

References get_time(), LOG_DEBUG, LOG_ERR, LOG_NOTICE, MSG_RESP, MSG_SYNC, n_log, netw, netw_bind_udp(), netw_close(), netw_udp_recvfrom(), netw_udp_sendto(), NETWORK_IPALL, and port.

Referenced by main(), and main().

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

◆ usage()

void usage ( const char * prog)
static

Definition at line 61 of file ex_clock_sync.c.