Practice ยท 1 of 3
Encode the Loopback Address
CHALLENGE
Difficulty: advanced+25 XP
POSIX. Implement void fill_loopback(struct sockaddr_in *sa, int port) โ zero the struct, set family AF_INET, address to INADDR_LOOPBACK (network byte order), and port (network byte order). Then implement int decode_port(const struct sockaddr_in *sa) returning the host-order port. NULL sa returns -1 from decode_port and does nothing in fill.
Press Submit to check your solution.
Back to lesson: Practice: Socket Drills on Loopback