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 = "";

    udp->Port  = UDP_PORT;

    udp->LocalPort  = UDP_PORT;



    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;




On my receive handler


void __fastcall TfrmPrincipal::udpDataAvailable(TObject *Sender,   WORD


  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


Receive and transmit.





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

Reply via email to