I am currently modifying Dennis Bush’s UFTP (http://uftp-multicast.sourceforge.net) to fit my needs. What I am currently trying to do is change the address to which the clients send the COMPLETE message. I would like the clients of my modified version of UFTP to multicast the COMPLETE messages instead of unicasting it back to the server, because I need every client in the multicast group to be able to see the COMPLETE messages that are sent, and not just the server.
The author of UFTP has told me that I should modify client_transfer.c, line 359, nb_sendto() function call, 5th argument to a structure containing the private multicast address and port to which I wish to send the COMPLETES. Unfortunately, I am getting the “Address family not supported by protocol” error. The code section was originally like this:
if (nb_sendto(listener, outpacket, payloadlen, 0,
(struct sockaddr *)&group_list[listidx].replyaddr,
sizeof(struct sockaddr_in)) == SOCKET_ERROR) {
sockerror(group_list[listidx].group_id, group_list[listidx].file_id,
"Error sending COMPLETE");
} else {
log(group_list[listidx].group_id, group_list[listidx].file_id,
"COMPLETE sent");
}
set_timeout(listidx);
free(buf);
free(encrypted);
My current code looks like this:
if (nb_sendto(listener, outpacket, payloadlen, 0,
////modified line:
(struct in_addr *)&group_list[listidx].multi.s_addr, //struct in_addr multi;
////end of modified line
sizeof(struct sockaddr_in)) == SOCKET_ERROR) {
sockerror(group_list[listidx].group_id, group_list[listidx].file_id,
"Error sending COMPLETE");
} else {
log(group_list[listidx].group_id, group_list[listidx].file_id,
"COMPLETE sent");
}
set_timeout(listidx);
free(buf);
free(encrypted);
The error is, to me, pretty vague. What exactly does it mean? What could be the possible causes of such an error? Could someone point me in the right direction?
If you are passing an
in_addrwhere asockaddris expected then the problem is simply that when the system call looks at what it thinks is the address family in what it thinks is a sockaddr structure it is really seeing one of the bytes of your multicast address, which is presumably not a valid address family.To explain more, a
sockaddr_inlooks like this:so the
in_addrhas a family and port number before it that you are not providing, and instead the first byte of your address is being treated as an address family.