Commit 1b08adbc authored by Davis King's avatar Davis King

Added overloads for listener::accept() that can take scoped_ptr

objects as well as normal connection pointers.  Also reconciled
the type used for timeouts between the win32 and posix version
of the code.

--HG--
extra : convert_revision : svn%3Afdd8eb12-d10e-0410-9acb-85c331704f74/trunk%402648
parent 82b16922
...@@ -397,6 +397,24 @@ namespace dlib ...@@ -397,6 +397,24 @@ namespace dlib
delete &listening_socket; delete &listening_socket;
} }
// ----------------------------------------------------------------------------------------
int listener::
accept (
scoped_ptr<connection>& new_connection,
unsigned long timeout
)
{
new_connection.reset(0);
connection* con;
int status = this->accept(con, timeout);
if (status == 0)
new_connection.reset(con);
return status;
}
// ---------------------------------------------------------------------------------------- // ----------------------------------------------------------------------------------------
int listener:: int listener::
......
...@@ -238,6 +238,11 @@ namespace dlib ...@@ -238,6 +238,11 @@ namespace dlib
unsigned long timeout = 0 unsigned long timeout = 0
); );
int accept (
scoped_ptr<connection>& new_connection,
unsigned long timeout = 0
);
unsigned short get_listening_port ( unsigned short get_listening_port (
) { return listening_port; } ) { return listening_port; }
......
...@@ -426,12 +426,30 @@ namespace dlib ...@@ -426,12 +426,30 @@ namespace dlib
} }
} }
// ----------------------------------------------------------------------------------------
int listener::
accept (
scoped_ptr<connection>& new_connection,
unsigned long timeout
)
{
new_connection.reset(0);
connection* con;
int status = this->accept(con, timeout);
if (status == 0)
new_connection.reset(con);
return status;
}
// ---------------------------------------------------------------------------------------- // ----------------------------------------------------------------------------------------
int listener:: int listener::
accept ( accept (
connection*& new_connection, connection*& new_connection,
int timeout unsigned long timeout
) )
{ {
int incoming; int incoming;
......
...@@ -283,7 +283,12 @@ namespace dlib ...@@ -283,7 +283,12 @@ namespace dlib
int accept ( int accept (
connection*& new_connection, connection*& new_connection,
int timeout = 0 unsigned long timeout = 0
);
int accept (
scoped_ptr<connection>& new_connection,
unsigned long timeout = 0
); );
int get_listening_port ( int get_listening_port (
......
...@@ -397,6 +397,15 @@ namespace dlib ...@@ -397,6 +397,15 @@ namespace dlib
- returns OTHER_ERROR if an error has occurred - returns OTHER_ERROR if an error has occurred
!*/ !*/
int accept (
scoped_ptr<connection>& new_connection,
unsigned long timeout = 0
);
/*!
This function is just an overload of the above function but it gives you a
scoped_ptr smart pointer instead of a C pointer.
!*/
unsigned short get_listening_port ( unsigned short get_listening_port (
) const; ) const;
/*! /*!
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment