mirror of
https://github.com/davisking/dlib.git
synced 2024-11-01 10:14:53 +08:00
Added some overloads of the create_connection() and create_listener()
functions that use scoped_ptr objects instead of just plain pointers. --HG-- extra : convert_revision : svn%3Afdd8eb12-d10e-0410-9acb-85c331704f74/trunk%402496
This commit is contained in:
parent
ea261db86c
commit
aa34d39f27
@ -526,8 +526,23 @@ namespace dlib
|
||||
// ----------------------------------------------------------------------------------------
|
||||
// ----------------------------------------------------------------------------------------
|
||||
|
||||
int
|
||||
create_listener (
|
||||
int create_listener (
|
||||
scoped_ptr<listener>& new_listener,
|
||||
unsigned short port,
|
||||
const std::string& ip
|
||||
)
|
||||
{
|
||||
new_listener.reset();
|
||||
listener* temp;
|
||||
int status = create_listener(temp,port,ip);
|
||||
|
||||
if (status == 0)
|
||||
new_listener.reset(temp);
|
||||
|
||||
return status;
|
||||
}
|
||||
|
||||
int create_listener (
|
||||
listener*& new_listener,
|
||||
unsigned short port,
|
||||
const std::string& ip
|
||||
@ -626,8 +641,25 @@ namespace dlib
|
||||
|
||||
// ----------------------------------------------------------------------------------------
|
||||
|
||||
int
|
||||
create_connection (
|
||||
int create_connection (
|
||||
scoped_ptr<connection>& new_connection,
|
||||
unsigned short foreign_port,
|
||||
const std::string& foreign_ip,
|
||||
unsigned short local_port,
|
||||
const std::string& local_ip
|
||||
)
|
||||
{
|
||||
new_connection.reset();
|
||||
connection* temp;
|
||||
int status = create_connection(temp,foreign_port, foreign_ip, local_port, local_ip);
|
||||
|
||||
if (status == 0)
|
||||
new_connection.reset(temp);
|
||||
|
||||
return status;
|
||||
}
|
||||
|
||||
int create_connection (
|
||||
connection*& new_connection,
|
||||
unsigned short foreign_port,
|
||||
const std::string& foreign_ip,
|
||||
|
@ -287,6 +287,20 @@ namespace dlib
|
||||
const std::string& local_ip
|
||||
);
|
||||
|
||||
int create_listener (
|
||||
scoped_ptr<listener>& new_listener,
|
||||
unsigned short port,
|
||||
const std::string& ip = ""
|
||||
);
|
||||
|
||||
int create_connection (
|
||||
scoped_ptr<connection>& new_connection,
|
||||
unsigned short foreign_port,
|
||||
const std::string& foreign_ip,
|
||||
unsigned short local_port = 0,
|
||||
const std::string& local_ip = ""
|
||||
);
|
||||
|
||||
// ----------------------------------------------------------------------------------------
|
||||
|
||||
|
||||
|
@ -676,8 +676,23 @@ namespace dlib
|
||||
|
||||
// ----------------------------------------------------------------------------------------
|
||||
|
||||
int
|
||||
create_listener (
|
||||
int create_listener (
|
||||
scoped_ptr<listener>& new_listener,
|
||||
unsigned short port,
|
||||
const std::string& ip
|
||||
)
|
||||
{
|
||||
new_listener.reset();
|
||||
listener* temp;
|
||||
int status = create_listener(temp,port,ip);
|
||||
|
||||
if (status == 0)
|
||||
new_listener.reset(temp);
|
||||
|
||||
return status;
|
||||
}
|
||||
|
||||
int create_listener (
|
||||
listener*& new_listener,
|
||||
unsigned short port,
|
||||
const std::string& ip
|
||||
@ -780,6 +795,24 @@ namespace dlib
|
||||
|
||||
// ----------------------------------------------------------------------------------------
|
||||
|
||||
int create_connection (
|
||||
scoped_ptr<connection>& new_connection,
|
||||
unsigned short foreign_port,
|
||||
const std::string& foreign_ip,
|
||||
unsigned short local_port,
|
||||
const std::string& local_ip
|
||||
)
|
||||
{
|
||||
new_connection.reset();
|
||||
connection* temp;
|
||||
int status = create_connection(temp,foreign_port, foreign_ip, local_port, local_ip);
|
||||
|
||||
if (status == 0)
|
||||
new_connection.reset(temp);
|
||||
|
||||
return status;
|
||||
}
|
||||
|
||||
int
|
||||
create_connection (
|
||||
connection*& new_connection,
|
||||
|
@ -32,6 +32,7 @@
|
||||
|
||||
#include "../threads.h"
|
||||
#include "../algs.h"
|
||||
#include "../smart_pointers.h"
|
||||
|
||||
|
||||
|
||||
@ -336,6 +337,20 @@ namespace dlib
|
||||
const std::string& local_ip
|
||||
);
|
||||
|
||||
int create_listener (
|
||||
scoped_ptr<listener>& new_listener,
|
||||
unsigned short port,
|
||||
const std::string& ip = ""
|
||||
);
|
||||
|
||||
int create_connection (
|
||||
scoped_ptr<connection>& new_connection,
|
||||
unsigned short foreign_port,
|
||||
const std::string& foreign_ip,
|
||||
unsigned short local_port = 0,
|
||||
const std::string& local_ip = ""
|
||||
);
|
||||
|
||||
// ----------------------------------------------------------------------------------------
|
||||
|
||||
}
|
||||
|
@ -110,6 +110,16 @@ namespace dlib
|
||||
- returns OTHER_ERROR if some other error occurred
|
||||
!*/
|
||||
|
||||
int create_listener (
|
||||
scoped_ptr<listener>& new_listener,
|
||||
unsigned short port,
|
||||
const std::string& ip = ""
|
||||
);
|
||||
/*!
|
||||
This function is just an overload of the above function but it gives you a
|
||||
scoped_ptr smart pointer instead of a C pointer.
|
||||
!*/
|
||||
|
||||
int create_connection (
|
||||
connection*& new_connection,
|
||||
unsigned short foreign_port,
|
||||
@ -137,6 +147,18 @@ namespace dlib
|
||||
- returns OTHER_ERROR if some other error occurred
|
||||
!*/
|
||||
|
||||
int create_connection (
|
||||
scoped_ptr<connection>& new_connection,
|
||||
unsigned short foreign_port,
|
||||
const std::string& foreign_ip,
|
||||
unsigned short local_port = 0,
|
||||
const std::string& local_ip = ""
|
||||
);
|
||||
/*!
|
||||
This function is just an overload of the above function but it gives you a
|
||||
scoped_ptr smart pointer instead of a C pointer.
|
||||
!*/
|
||||
|
||||
// ----------------------------------------------------------------------------------------
|
||||
// ----------------------------------------------------------------------------------------
|
||||
// connection object
|
||||
@ -200,7 +222,7 @@ namespace dlib
|
||||
|
||||
void* user_data;
|
||||
/*!
|
||||
This pointer is provided so that the client programmer may easily assocaite
|
||||
This pointer is provided so that the client programmer may easily associate
|
||||
some data with a connection object. You can really do whatever you want
|
||||
with it. Initially user_data is 0.
|
||||
!*/
|
||||
@ -372,7 +394,7 @@ namespace dlib
|
||||
|
||||
- returns 0 if accept() was successful
|
||||
- returns TIMEOUT if timeout milliseconds have elapsed
|
||||
- returns OTHER_ERROR if an error has occured
|
||||
- returns OTHER_ERROR if an error has occurred
|
||||
!*/
|
||||
|
||||
unsigned short get_listening_port (
|
||||
|
Loading…
Reference in New Issue
Block a user