struct sockaddr_in address; 
short port = 9998;
address.sin_family = AF_INET;
address.sin_port = htons (port);
address.sin_addr.s_addr = inet_addr("127.0.0.1");
 

When you bind() to a socket, the address.sin_addr.s_addr should be NULL. When you sendto() a socket, you need to specify the address as shown above.

Also, page 490 of your book has some TCP networking code. Remember, we are using UDP.