diff --git a/repos/dde_linux/src/test/lxip/udp_client/main.cc b/repos/dde_linux/src/test/lxip/udp_client/main.cc
index 82d2848e4e..829b88861b 100644
--- a/repos/dde_linux/src/test/lxip/udp_client/main.cc
+++ b/repos/dde_linux/src/test/lxip/udp_client/main.cc
@@ -12,7 +12,10 @@
*/
/* Genode includes */
-#include
+#include
+#include
+#include
+#include
/* libc includes */
#include
@@ -21,25 +24,25 @@
#include
#include
#include
-#include
-#include
using namespace Genode;
-int main(void)
+
+struct Failure : Genode::Exception { };
+
+
+static void client_loop(Genode::Xml_node config_node, Timer::Connection &timer)
{
int s;
- static Timer::Connection _timer;
log("Start the client loop ...");
for(int j = 0; j != 5; ++j) {
- _timer.msleep(2000);
+ timer.msleep(2000);
if((s = socket(AF_INET, SOCK_DGRAM, 0)) < 0) {
error("No socket available!");
- return -1;
+ throw Failure();
}
enum { ADDR_STR_SZ = 16 };
char serv_addr[ADDR_STR_SZ] = { 0 };
- Xml_node config_node = config()->xml_node();
try { config_node.attribute("server_ip").value(serv_addr, ADDR_STR_SZ); }
catch(...) {
error("Missing \"server_ip\" attribute.");
@@ -72,8 +75,24 @@ int main(void)
}
log("Received \"", String<64>(buf), " ...\"");
}
- _timer.msleep(2000);
+ timer.msleep(2000);
log("Test done");
- return 0;
}
+
+
+struct Main
+{
+ Main(Genode::Env &env)
+ {
+ Genode::Attached_rom_dataspace config_rom { env, "config" };
+ Timer::Connection timer { env };
+
+ Libc::with_libc([&] () {
+ client_loop(config_rom.xml(), timer);
+ });
+ }
+};
+
+
+void Libc::Component::construct(Libc::Env &env) { static Main main(env); }
diff --git a/repos/dde_linux/src/test/lxip/udp_client/target.mk b/repos/dde_linux/src/test/lxip/udp_client/target.mk
index a74884f2d1..1a2898aa89 100644
--- a/repos/dde_linux/src/test/lxip/udp_client/target.mk
+++ b/repos/dde_linux/src/test/lxip/udp_client/target.mk
@@ -1,3 +1,3 @@
TARGET = test-lxip_udp_client
-LIBS = posix libc_lxip config
+LIBS = libc libc_lxip
SRC_CC = main.cc