I compiled the same sample code (
I suppose[
^]), on my Lubuntu 15.10 Box.
Got the following output:
(build process)
gcc -g -c -o udp-send.o udp-send.c
udp-send.c: In function ‘main’:
udp-send.c:54:6: warning: implicit declaration of function ‘inet_aton’ [-Wimplicit-function-declaration]
if (inet_aton(server, &remaddr.sin_addr)==0) {
^
udp-send.c:75:2: warning: implicit declaration of function ‘close’ [-Wimplicit-function-declaration]
close(fd);
^
gcc -o udp-send udp-send.o
gcc -g -c -o udp-recv.o udp-recv.c
gcc -o udp-recv udp-recv.o
(server execution)
~/devel/junk/demo-udp-04$ ./udp-recv
waiting on port 21234
received message: "This is packet 0" (16 bytes)
sending response "ack 0"
waiting on port 21234
received message: "This is packet 1" (16 bytes)
sending response "ack 1"
waiting on port 21234
received message: "This is packet 2" (16 bytes)
sending response "ack 2"
waiting on port 21234
received message: "This is packet 3" (16 bytes)
sending response "ack 3"
waiting on port 21234
received message: "This is packet 4" (16 bytes)
sending response "ack 4"
waiting on port 21234
(client execution)
Sending packet 0 to 127.0.0.1 port 21234
received message: "ack 0"
Sending packet 1 to 127.0.0.1 port 21234
received message: "ack 1"
Sending packet 2 to 127.0.0.1 port 21234
received message: "ack 2"
Sending packet 3 to 127.0.0.1 port 21234
received message: "ack 3"
Sending packet 4 to 127.0.0.1 port 21234
received message: "ack 4"