diff options
author | kdx <kikoodx@paranoici.org> | 2023-08-30 05:47:28 +0200 |
---|---|---|
committer | kdx <kikoodx@paranoici.org> | 2023-08-30 05:47:28 +0200 |
commit | 26c07567cce84277d024317d7c0caff78b335fce (patch) | |
tree | 68369e6841ed53615f552a274e5713e4147dbec1 | |
parent | db4dad0aff36cecf2cf5b61d1b60dd03ac86e086 (diff) | |
download | premovechess-26c07567cce84277d024317d7c0caff78b335fce.tar.gz |
ping every frame
-rw-r--r-- | inc/netcode.h | 2 | ||||
-rw-r--r-- | src/main.c | 5 | ||||
-rw-r--r-- | src/netcode.c | 9 |
3 files changed, 16 insertions, 0 deletions
diff --git a/inc/netcode.h b/inc/netcode.h index ac1bb18..148a519 100644 --- a/inc/netcode.h +++ b/inc/netcode.h @@ -8,3 +8,5 @@ void netcode_deinit(void); int netcode_send(void *data, size_t size); int netcode_recv(void *data, size_t size); + +int netcode_ping(void); @@ -51,5 +51,10 @@ main_loop(void *udata) TZR_DrawBegin(); TZR_DrawEnd(); + if (netcode_ping()) { + log_error("netcode_ping failed"); + return -1; + } + return 0; } diff --git a/src/netcode.c b/src/netcode.c index b3ac6c3..5ae5990 100644 --- a/src/netcode.c +++ b/src/netcode.c @@ -99,3 +99,12 @@ netcode_recv(void *data, size_t size) } return 0; } + +int +netcode_ping(void) +{ + char a = 0; + if (_sock_host != NULL) + return netcode_recv(&a, 1); + return netcode_send(&a, 1); +} |