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.

Definition at line 53 of file ex_clock_sync.c.

◆ MODE_SERVER

#define MODE_SERVER   0
Examples
ex_clock_sync.c.

Definition at line 52 of file ex_clock_sync.c.

◆ MSG_RESP

#define MSG_RESP   "RESP"

sync response message: "RESP client_send_time server_time\n"

Examples
ex_clock_sync.c.

Definition at line 58 of file ex_clock_sync.c.

◆ MSG_SYNC

#define MSG_SYNC   "SYNC"

sync request message: "SYNC client_send_time\n"

Examples
ex_clock_sync.c.

Definition at line 56 of file ex_clock_sync.c.

Function Documentation

◆ get_time()

static double get_time ( void  )
static
Examples
ex_clock_sync.c.

Definition at line 76 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 230 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()

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

◆ run_server()

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

Definition at line 82 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().

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

◆ usage()

static void usage ( const char *  prog)
static

Definition at line 60 of file ex_clock_sync.c.