Invalid return value for "sendto" socket function
Hello,
I am using Ubuntu 10.04 on virtual box. (Host OS : Windows XP) I am trying to send UDP packets to another machine using socket programming. Here is a piece of code. Code:
#include <stdio.h> Here, sendto function always returns "-1" and printed error message is "Error =Invalid argument, 16" I cross verified the parameter values, it seems to be fine. Could anybody point me if I am doing anything wrong here??? Thanks in advance. |
You don't need bind source IP address.
|
I commented out "Bind function".
Yet Sendto function returns "Error =Invalid argument, 16". I was able to run this code successfully on PC where LINUX is host OS. |
Change code like this.
Original code: x_sockaddr_out.sin_family= AF_INET; x_sockaddr_out.sin_addr.s_addr = htonl(DST_IP_ADDR); x_sockaddr_out.sin_port = htonl(macRemotePort); bzero(&(x_sockaddr_out.sin_zero),8); New code bzero(&x_sockaddr_out,sizeof(x_sockaddr_out)) x_sockaddr_out.sin_family= AF_INET; x_sockaddr_out.sin_addr.s_addr = htonl(DST_IP_ADDR); x_sockaddr_out.sin_port = htonl(macRemotePort); |
All times are GMT -5. The time now is 08:54 PM. |