akhila
April 1st, 1999, 03:38 AM
Hello,
I am using SDK sockets to broadcast UDP frames. I have set the socket option with SO_BROADCAST to enable the socket in
broadcast mode.
The following is the code listing which starts from the formation of the destination address:
destAddr.sin_family = AF_INET;
destAddr.sin_port = SERVER_UDP_PORT;
destAddr.sin_addr.s_addr = 0xffffffff; //Local Broadcast;
/*************setting the socket option to enable the socket for broadcast mode ****/
int optionValue =1;
int optLen = sizeof(int);
if(setsockopt(tspiUdpSocket,SOL_SOCKET ,SO_BROADCAST, (char*)&optionValue ,optLen ) == SOCKET_ERROR)
{
LogError("LANfone TSPI InitSocks:ERROR: Failed to SET SOCKET OPTION for udp socket function");
closesocket(tspiUdpSocket);
return FAIL;
}
/**********sending to the server ********************/
nSentBytes = sendto(tspiUdpSocket,sendBuffer,sSize,0,(SOCKADDR*)&destAddr, sizeof(SOCKADDR_IN));
Here the nSentBytes is returning the correct number of bytes sent but the other end is not receiving the packet. The
same concept works with MFC sockets. The receiver recvs the packet without any problem. With SDK sockets it does not
seem to work.
Can anyone please help at the earliest????
Thanks.
Akhila
I am using SDK sockets to broadcast UDP frames. I have set the socket option with SO_BROADCAST to enable the socket in
broadcast mode.
The following is the code listing which starts from the formation of the destination address:
destAddr.sin_family = AF_INET;
destAddr.sin_port = SERVER_UDP_PORT;
destAddr.sin_addr.s_addr = 0xffffffff; //Local Broadcast;
/*************setting the socket option to enable the socket for broadcast mode ****/
int optionValue =1;
int optLen = sizeof(int);
if(setsockopt(tspiUdpSocket,SOL_SOCKET ,SO_BROADCAST, (char*)&optionValue ,optLen ) == SOCKET_ERROR)
{
LogError("LANfone TSPI InitSocks:ERROR: Failed to SET SOCKET OPTION for udp socket function");
closesocket(tspiUdpSocket);
return FAIL;
}
/**********sending to the server ********************/
nSentBytes = sendto(tspiUdpSocket,sendBuffer,sSize,0,(SOCKADDR*)&destAddr, sizeof(SOCKADDR_IN));
Here the nSentBytes is returning the correct number of bytes sent but the other end is not receiving the packet. The
same concept works with MFC sockets. The receiver recvs the packet without any problem. With SDK sockets it does not
seem to work.
Can anyone please help at the earliest????
Thanks.
Akhila