File: udp-test-server.c

package info (click to toggle)
libosmo-netif 1.6.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 1,764 kB
  • sloc: ansic: 11,830; makefile: 261; sh: 85
file content (35 lines) | stat: -rw-r--r-- 515 bytes parent folder | download | duplicates (4)
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;
}