|
|
@ -59,6 +59,7 @@ namespace dlib
|
|
|
|
const network_address& addr
|
|
|
|
const network_address& addr
|
|
|
|
)
|
|
|
|
)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
|
|
|
|
auto_mutex lock(class_mutex);
|
|
|
|
close();
|
|
|
|
close();
|
|
|
|
con.reset(connect(addr));
|
|
|
|
con.reset(connect(addr));
|
|
|
|
buf.reset(new sockstreambuf(con.get()));
|
|
|
|
buf.reset(new sockstreambuf(con.get()));
|
|
|
@ -79,6 +80,7 @@ namespace dlib
|
|
|
|
unsigned long timeout
|
|
|
|
unsigned long timeout
|
|
|
|
)
|
|
|
|
)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
|
|
|
|
auto_mutex lock(class_mutex);
|
|
|
|
close(timeout);
|
|
|
|
close(timeout);
|
|
|
|
con.reset(connect(addr.host_address, addr.port, timeout));
|
|
|
|
con.reset(connect(addr.host_address, addr.port, timeout));
|
|
|
|
buf.reset(new sockstreambuf(con.get()));
|
|
|
|
buf.reset(new sockstreambuf(con.get()));
|
|
|
@ -91,6 +93,7 @@ namespace dlib
|
|
|
|
unsigned long timeout = 10000
|
|
|
|
unsigned long timeout = 10000
|
|
|
|
)
|
|
|
|
)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
|
|
|
|
auto_mutex lock(class_mutex);
|
|
|
|
rdbuf(0);
|
|
|
|
rdbuf(0);
|
|
|
|
try
|
|
|
|
try
|
|
|
|
{
|
|
|
|
{
|
|
|
@ -126,12 +129,21 @@ namespace dlib
|
|
|
|
unsigned long timeout
|
|
|
|
unsigned long timeout
|
|
|
|
)
|
|
|
|
)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
|
|
|
|
auto_mutex lock(class_mutex);
|
|
|
|
if (con)
|
|
|
|
if (con)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
con_timeout.reset(new dlib::timeout(*this,&iosockstream::terminate_connection,timeout,con));
|
|
|
|
con_timeout.reset(new dlib::timeout(*this,&iosockstream::terminate_connection,timeout,con));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void shutdown (
|
|
|
|
|
|
|
|
)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
auto_mutex lock(class_mutex);
|
|
|
|
|
|
|
|
if (con)
|
|
|
|
|
|
|
|
con->shutdown();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private:
|
|
|
|
private:
|
|
|
|
|
|
|
|
|
|
|
|
void terminate_connection(
|
|
|
|
void terminate_connection(
|
|
|
@ -142,6 +154,7 @@ namespace dlib
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
scoped_ptr<timeout> con_timeout;
|
|
|
|
scoped_ptr<timeout> con_timeout;
|
|
|
|
|
|
|
|
rmutex class_mutex;
|
|
|
|
shared_ptr_thread_safe<connection> con;
|
|
|
|
shared_ptr_thread_safe<connection> con;
|
|
|
|
scoped_ptr<sockstreambuf> buf;
|
|
|
|
scoped_ptr<sockstreambuf> buf;
|
|
|
|
|
|
|
|
|
|
|
|