Skip to content

Commit

Permalink
add udp socket and example
Browse files Browse the repository at this point in the history
  • Loading branch information
thatstoasty committed Jan 13, 2025
1 parent d118339 commit 4ecef71
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 0 deletions.
1 change: 1 addition & 0 deletions mojoproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ publish = { cmd = "bash scripts/publish.sh", env = { PREFIX_API_KEY = "$PREFIX_A
test = { cmd = "magic run mojo test -I . tests/lightbug_http" }
integration_tests_py = { cmd = "bash scripts/integration_test.sh" }
integration_tests_external = { cmd = "magic run mojo test -I . tests/integration" }
integration_tests_udp = { cmd = "bash scripts/udp_test.sh" }
bench = { cmd = "magic run mojo -I . benchmark/bench.mojo" }
bench_server = { cmd = "bash scripts/bench_server.sh" }
format = { cmd = "magic run mojo format -l 120 lightbug_http" }
Expand Down
22 changes: 22 additions & 0 deletions scripts/udp_test.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#!/bin/bash
echo "[INFO] Building mojo binaries.."

kill_server() {
pid=$(ps aux | grep "$1" | grep -v grep | awk '{print $2}' | head -n 1)
kill $pid
wait $pid 2>/dev/null
}

(magic run mojo build -D LB_LOG_LEVEL=DEBUG -I . --debug-level full tests/integration/udp/udp_server.mojo)
(magic run mojo build -D LB_LOG_LEVEL=DEBUG -I . --debug-level full tests/integration/udp/udp_client.mojo)

echo "[INFO] Starting UDP server..."
./udp_server &
sleep 5

echo "[INFO] Testing server with UDP client"
./udp_client

rm ./udp_server
rm ./udp_client
kill_server "udp_server"
File renamed without changes.
File renamed without changes.

0 comments on commit 4ecef71

Please sign in to comment.