Montrer les appels systèmes avec :
$ strace nc -l -p 4000
...
socket(PF_INET, SOCK_STREAM, IPPROTO_TCP) = 3
setsockopt(3, SOL_SOCKET, SO_REUSEADDR, [1], 4) = 0
bind(3, {sin_family=AF_INET, sin_port=htons(4000),
sin_addr=inet_addr("0.0.0.0")}}, 16) = 0
listen(3, 1) = 0
rt_sigaction(SIGALRM, {SIG_IGN}, {SIG_DFL}, 8) = 0
alarm(0) = 0
accept(3,
Montrer le fonctionnement d’un serveur UDP :
# strace -f nc -u -l -p 4000
...
socket(PF_INET, SOCK_DGRAM, IPPROTO_UDP) = 3
setsockopt(3, SOL_SOCKET, SO_REUSEADDR, [1], 4) = 0
bind(3, {sin_family=AF_INET, sin_port=htons(4000), sin_addr=inet_addr("0.0.0.0")}}, 16) = 0
rt_sigaction(SIGALRM, {SIG_IGN}, {SIG_DFL}, 8) = 0
alarm(0) = 0
recvfrom(3, ...
... {sin_family=AF_INET, sin_port=htons(4000),
sin_addr=inet_addr("127.0.0.1")}}, [16]) = 0
select(16, [0 3], NULL, NULL, NULL) = 1 (in [3])
read(3, "\n", 8192) = 1
write(1, "\n", 1) = 1
...
# strace nc -u localhost 4000
socket(PF_INET, SOCK_DGRAM, IPPROTO_UDP) = 3
setsockopt(3, SOL_SOCKET, SO_REUSEADDR, [1], 4) = 0
rt_sigaction(SIGALRM, {SIG_IGN}, {SIG_DFL}, 8) = 0
alarm(0) = 0
connect(3, {sin_family=AF_INET, sin_port=htons(4000),
sin_addr=inet_addr("127.0.0.1")}}, 16) = 0
rt_sigaction(SIGALRM, {SIG_IGN}, {SIG_IGN}, 8) = 0
alarm(0) = 0
select(16, [0 3], NULL, NULL, NULL) = 1 (in [0])
read(0, "\n", 8192) = 1
write(3, "\n", 1) = 1
...