// sending code
int main() {
strace(1);
int sock_fd = socket(AF_INET, SOCK_DGRAM, PROTO_UDP);
bind0(sock_fd, 0x0a00020f /* 10.0.2.15 */, 4);
connect0(sock_fd, 0x0a000202 /* 10.0.2.2 */, 1330);
write(sock_fd, "Hello World\n", 12);
printf("data sent\n");
char recv[128] = {0};
read(sock_fd, recv, 128);
printf("received: '%s'\n", recv);
}
// trace of execution
$ net
strace(true) -> { value = 0, error = 0 };
socket(0, 0, 17) -> { value = 3, error = 0 };
bind0(3, 0xa00020f, 4) -> { value = 0, error = 0 };
connect0(3, 0xa000202, 1330) -> { value = 0, error = 0 };
write(3, 401800, c)sending packet at vma:0xffffffff801cc458, pma:0x193458, len:54
-> { value = c, error = 0 };
write(1, 7ffffefffbf8, a)data sent
-> { value = a, error = 0 };
<quit>
// listening on port 1330
tyler@xps:~/nightingale/kernel/net$ nc -u -l 1330
Hello World
Comments