Results 1 to 6 of 6

Thread: CL_UDPSocket crash when sending to unbound server

  1. #1

    Default CL_UDPSocket crash when sending to unbound server

    I'm experiencing issues whereby if I attempt to send a udp packet to an ip that isn't bound to accept it, my application will crash. I'm using CL_UDPSocket->send, how can I avoid this crash, and have it handled gracefully?

    Thanks!

  2. #2
    ClanLib Developer
    Join Date
    Sep 2006
    Location
    Denmark
    Posts
    554

    Default

    Do you have a small example demonstrating this crash?

  3. #3

    Default

    You should be able to reproduce this crash on Windows by simply binding a UDP socket with CL_UDPSocket->bind, and then attempting to use CL_UDPSocket->send to "localhost" but using a port that is not bound.

    For example:

    CL_UDPSocket* gSocket = new CL_UDPSocket;
    gSocket->bind(CL_SocketName("7505"));
    std::string data = "Some string";

    gSocket->send(data.data(), data.length(), CL_SocketName("localhost", "8585")); //try send data to unbound port

  4. #4
    ClanLib Developer
    Join Date
    Sep 2006
    Location
    Denmark
    Posts
    554

    Default

    Just tried the following code with ClanLib 3.0 SVN:

    Code:
    using namespace clan;
    
    SetupNetwork setup_network;
    
    UDPSocket socket;
    socket.bind(SocketName("5001"));
    socket.send("foobarism", 9, SocketName("localhost", "5002"));
    It did not cause any crash.

    Are you catching any possible exceptions that could be thrown?

  5. #5

    Default

    Quote Originally Posted by Magnus Norddahl View Post
    Just tried the following code with ClanLib 3.0 SVN:

    Code:
    using namespace clan;
    
    SetupNetwork setup_network;
    
    UDPSocket socket;
    socket.bind(SocketName("5001"));
    socket.send("foobarism", 9, SocketName("localhost", "5002"));
    It did not cause any crash.

    Are you catching any possible exceptions that could be thrown?
    I'm using 2.3.7

  6. #6
    ClanLib Developer
    Join Date
    Sep 2006
    Location
    Denmark
    Posts
    554

    Default

    To my knowledge there aren't any differences between those two versions (except that one uses namespaces and the other uses the CL_ prefix.

    Maybe you should try set a breakpoint at the line that crashes and then step into the function to see what is going wrong?

Similar Threads

  1. server crash!!!!!!!!!!!
    By jakob12 in forum Bugs & Glitches
    Replies: 4
    Last Post: 03-15-2013, 03:51 PM
  2. Sending message to server
    By croland in forum Official ClanLib SDK Forums
    Replies: 2
    Last Post: 12-24-2006, 03:56 PM

Bookmarks

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •