Hi all,
I have build a new app that need to use udp datagram.
The Application need to be able to receive OR send datagram. So I don't know
if I need to use Listen OR connect on my socket.
What property I need to initialise to do this ?
Righ now I hve this setup
udp->Addr = "0.0.0.0";
udp->Port = UDP_PORT;
udp->LocalPort = UDP_PORT;
udp->Listen();
int optval = 1;
setsockopt(udp->HSocket, SOL_SOCKET, SO_BROADCAST , (char *)&optval,
sizeof optval);
In the transmit function:
void BACnet::sendBuffer(AnsiString ipAdr,int port,char *buffer,int length)
{
TSockAddrIn Ffrom;
int FSrcLen;
FSrcLen = sizeof(Ffrom);
Ffrom.sin_port = htons(port);
Ffrom.sin_family = AF_INET;
udp->SendTo(Ffrom,FSrcLen,buffer,length);
}
On my receive handler
void __fastcall TfrmPrincipal::udpDataAvailable(TObject *Sender, WORD
ErrCode)
{
TSockAddrIn Ffrom;
int FSrcLen;
BACnet::BACnetIPPacket_t packet;
char buffer[MAX_APDU];
char data[MAX_APDU];
int NumberBytes;
NumberBytes = udp->ReceiveFrom( data,MAX_APDU,Ffrom,FSrcLen);
if( NumberBytes > 0)
{
// do the job
}
}
When I do this,
Sometime when my application start, the CPU goes to 100% and never get back.
I would like to know if I missed some property setting ?
I need UDP datagram
Broadcast
Receive and transmit.
Regards
Jonathan
--
To unsubscribe or change your settings for TWSocket mailing list
please goto http://lists.elists.org/cgi-bin/mailman/listinfo/twsocket
Visit our website at http://www.overbyte.be