Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions examples/genericscp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,11 @@ int main()
{
dispatcher.dispatch();
}
catch(odil::dul::SocketClosed const &)
{
std::cout << "Peer closed the socket" << std::endl;
done = true;
}
catch(odil::AssociationReleased const &)
{
std::cout << "Peer released association" << std::endl;
Expand Down
5 changes: 5 additions & 0 deletions src/odil/dul/Transport.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -262,6 +262,11 @@ ::_run(Source & source, boost::system::error_code & error)

if(source == Source::OPERATION)
{
if(error == boost::asio::error::eof)
{
throw SocketClosed();
}

if(error)
{
throw Exception("Operation error: "+error.message());
Expand Down
16 changes: 16 additions & 0 deletions src/odil/dul/Transport.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
#include <boost/asio.hpp>
#include <boost/date_time.hpp>

#include "odil/Exception.h"

namespace odil
{

Expand Down Expand Up @@ -102,6 +104,20 @@ struct Transport
void _run(Source & source, boost::system::error_code & error);
};


/**
* @brief Exception reported when the socket is closed without releasing the association.
*/
class SocketClosed: public Exception
{
public:
SocketClosed()
: Exception("Socket closed")
{
// Nothing else.
}
};

}

}
Expand Down