lxip/udp_client: create new socket on every run

Instead of creating one socket and re-using it each test run because the
client shall also test the termination of pseudo-connections at components that
implement hole punching for UDP.

Ref #2139
This commit is contained in:
Martin Stein 2016-10-17 13:12:42 +02:00 committed by Christian Helmuth
parent cdd05ad71b
commit 3a7ae03f79

View File

@ -30,21 +30,13 @@ int main(void)
{
int s;
static Timer::Connection _timer;
log("Start the client loop ...");
for(int j = 0; j != 5; ++j) {
_timer.msleep(2000);
log("Create new socket ...");
if((s = socket(AF_INET, SOCK_DGRAM, 0)) < 0) {
error("No socket available!");
return -1;
}
log("Now, I will bind ...");
struct sockaddr_in in_addr;
in_addr.sin_family = AF_INET;
in_addr.sin_port = htons(49252);
in_addr.sin_addr.s_addr = INADDR_ANY;
if(bind(s, (struct sockaddr*)&in_addr, sizeof(in_addr))) {
error("bind failed!");
return -1;
}
enum { ADDR_STR_SZ = 16 };
char serv_addr[ADDR_STR_SZ] = { 0 };
Xml_node libc_node = config()->xml_node().sub_node("libc");
@ -59,9 +51,6 @@ int main(void)
error("Missing \"server_port\" attribute.");
throw Xml_node::Nonexistent_attribute();
}
log("Start the client loop ...");
for(int j = 0; j != 5; ++j) {
_timer.msleep(2000);
struct sockaddr_in addr;
addr.sin_family = AF_INET;
socklen_t len = sizeof(addr);