aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorcbdev <cb@cbcdn.com>2024-01-14 12:49:32 +0100
committercbdev <cb@cbcdn.com>2024-01-14 12:49:32 +0100
commita5f6fd78366b7a647841138510f05ce36a001627 (patch)
treeb40b2ac66c37f3fa7a5be1fca63d8e2050b9f42f
parent3673022f5752b905c04f083387dfbdfae9d7b664 (diff)
downloadwebsocksy-a5f6fd78366b7a647841138510f05ce36a001627.tar.gz
websocksy-a5f6fd78366b7a647841138510f05ce36a001627.tar.bz2
websocksy-a5f6fd78366b7a647841138510f05ce36a001627.zip
Implement udp-listen peer transport
-rw-r--r--websocksy.c10
-rw-r--r--websocksy.h1
2 files changed, 10 insertions, 1 deletions
diff --git a/websocksy.c b/websocksy.c
index 5c29f8c..208e9e6 100644
--- a/websocksy.c
+++ b/websocksy.c
@@ -102,6 +102,10 @@ static peer_transport client_detect_transport(char* host){
memmove(host, host + 6, strlen(host) - 5);
return peer_udp_client;
}
+ else if(!strncmp(host, "udp-listen://", 13)){
+ memmove(host, host + 13, strlen(host) - 13);
+ return peer_udp_listen;
+ }
else if(!strncmp(host, "fifotx://", 9)){
memmove(host, host + 9, strlen(host) - 8);
return peer_fifo_tx;
@@ -154,7 +158,7 @@ int client_connect(websocket* ws){
ws->peer.transport = client_detect_transport(ws->peer.host);
}
- if((ws->peer.transport == peer_tcp_client || ws->peer.transport == peer_udp_client)
+ if((ws->peer.transport == peer_tcp_client || ws->peer.transport == peer_udp_client || ws->peer.transport == peer_udp_listen)
&& !ws->peer.port){
ws->peer.port = client_detect_port(ws->peer.host);
if(!ws->peer.port){
@@ -171,6 +175,10 @@ int client_connect(websocket* ws){
case peer_udp_client:
ws->peer_fd = network_socket(ws->peer.host, ws->peer.port, SOCK_DGRAM, 0);
break;
+ case peer_udp_listen:
+ //FIXME this might create issues when multiple clients connect and expect to receive all incoming messages
+ ws->peer_fd = network_socket(ws->peer.host, ws->peer.port, SOCK_DGRAM, 1);
+ break;
case peer_fifo_tx:
case peer_fifo_rx:
//TODO implement other peer modes
diff --git a/websocksy.h b/websocksy.h
index 64dcc8d..4f9b91a 100644
--- a/websocksy.h
+++ b/websocksy.h
@@ -93,6 +93,7 @@ typedef enum {
peer_transport_detect,
peer_tcp_client,
peer_udp_client,
+ peer_udp_listen,
peer_fifo_tx,
peer_fifo_rx,
peer_unix_stream,