diff options
-rw-r--r-- | websocksy.c | 10 | ||||
-rw-r--r-- | websocksy.h | 1 |
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, |