1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35
|
#include "udp-test.h"
int read_cb(struct osmo_dgram *conn)
{
int bytes;
struct msgb *msg = print_recv(conn);
if (!msg)
return -1;
/* build reply: */
bytes = msgb_length(msg);
if (!mtrim(msg, 0, bytes))
return -1;
/* sent reply: */
osmo_dgram_send(conn, msg);
/* end test: */
if (bytes > NUM_MSG - 1)
please_dont_die = false;
return 0;
}
int main(int argc, char **argv)
{
if (!dgram_init(THOST, SPORT, CPORT, read_cb))
return EXIT_FAILURE;
main_loop(THOST, SPORT, CPORT);
return 0;
}
|