summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorkdx <kikoodx@paranoici.org>2023-08-30 05:47:28 +0200
committerkdx <kikoodx@paranoici.org>2023-08-30 05:47:28 +0200
commit26c07567cce84277d024317d7c0caff78b335fce (patch)
tree68369e6841ed53615f552a274e5713e4147dbec1
parentdb4dad0aff36cecf2cf5b61d1b60dd03ac86e086 (diff)
downloadpremovechess-26c07567cce84277d024317d7c0caff78b335fce.tar.gz
ping every frame
-rw-r--r--inc/netcode.h2
-rw-r--r--src/main.c5
-rw-r--r--src/netcode.c9
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);
diff --git a/src/main.c b/src/main.c
index 68080b6..b56f427 100644
--- a/src/main.c
+++ b/src/main.c
@@ -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);
+}