C++ .Net UDP Socket Endpoint question

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • keelo
    New Member
    • Nov 2012
    • 1

    C++ .Net UDP Socket Endpoint question

    I have a small c++ .net program that is intended to be a simple UDP server; however, I just want to start blasting out packets when a connection is made.

    After setup,

    Socket^ socket = gcnew Socket(AddressF amily::InterNet work, SocketType::Dgr am, ProtocolType::U dp);
    IPEndPoint^ ipep = gcnew IPEndPoint(IPAd dress::Any, 54321);

    socket->Bind(ipep);

    while(true)
    {
    array<unsigned char>^ message = gcnew array<unsigned char>(1024);
    EndPoint^ Remote = (EndPoint^) gcnew IPEndPoint (IPAddress::Any , 0);

    int recv = socket->ReceiveFrom(me ssage, Remote);

    So, the above blocks until a message arrives, then I can write to the endpoint.

    What I am trying to understand is, is what is the proper combination of listen/accept/etc... can I block on until I get a connection (endpoint) which I can start writing to.

    Pulling what's left of my hair out.
Working...