Socket wiederverwenden mit boost asio

Ich versuche es mal mit einem boost-asio-socket an eine lokale Adresse/port-Kombination. Das funktioniert Super. Was nicht funktioniert, ist erneut mit von der Steckdose, sobald die Buchse und die Anwendung wurde beendet und neu gestartet.

    //
    //open the socket - it would also be opened by the async_connect() 
    //method but we might need an open socket to bind it
    _socket.open(boost::asio::ip::tcp::v4());

    if ( _bindLocal ) {
        boost::asio::socket_base::reuse_address option(true);
        _socket.set_option(option);
        _socket.bind( _localEndpoint );
    }

    //Invoke async. connect. Immediate return, no throw.
    _socket.async_connect(_remoteEndpoint,
        boost::bind(&MyTransceiver::handleConnect, this,
            boost::asio::placeholders::error));

Was bin ich? Ist die Bestellung von der open(), set_option() und bind () - Aufruf korrekt?

InformationsquelleAutor PMiller | 2011-12-08
Schreibe einen Kommentar