This is a follow-up of another post with the title "address family not supported by protocol family." I couldn't quite solve the problem, but I discover another problem that may cause the problem in the above post.
<br><br>In a nutshell, I have a receiver program which waits to receive data from a sender program, and send an ack back. Because I couldn&#39;t solve the above problem, I reduced the program to an earlier version that worked and traced my code additions, and I got this: the simple receiver was working, then I added a declaration of a dummy variable in the main function, and the program stopped working. The error was thrown in another function whose caller&#39;s caller&#39;s is called by main. The error is thrown by a sendto(), and it was &quot;Invalid argument&quot;.
<br><br>Since there was a post from the last project about &quot;segfault madness&quot; in which a segfault appeared after a declaration of a dummy variable, I followed the suggestions in that post. Therefore, I compiled my code with -g -Wall, and got a bunch of warnings about unused variables, and several print functions where I didn&#39;t print with the right flags (
e.g. print void* with %x or %c, or something else with %ld, can this be the issue?). <br><br>I ignored the warnings and ran the program with gdb. Since the error was invalid arguments, I checked the argument passed to sendto() namely the socket file descriptor, the sockaddr_in and the addrlen (didn&#39;t check the buffer and its size closely, but the buffer is not null, and the size is the right non-zero number). By printing these variables with gdb (and gdb on my computer let me see the content of the variable in a nice format with all the field names in front of the data), I can visually verify that the data passed to sendto() is the same data that was returned by the recvfrom() in main(). (Recall that the receiver receives something then send and ack.) At this point, I&#39;m stuck because the arguments appear valid to me.
<br><br>Any clue about how to debug this thing or where the bug can be would be much appreciated.<br clear="all"><br>-- <br>Haley Nguyen