Commit 7ac39721 authored by Davis King's avatar Davis King

Added a get_socket_descriptor() function to the connection class.

--HG--
extra : convert_revision : svn%3Afdd8eb12-d10e-0410-9acb-85c331704f74/trunk%402903
parent 3f7abc83
...@@ -367,6 +367,15 @@ namespace dlib ...@@ -367,6 +367,15 @@ namespace dlib
return temp; return temp;
} }
// ----------------------------------------------------------------------------------------
connection::socket_descriptor_type connection::
get_socket_descriptor (
) const
{
return connection_socket.val;
}
// ---------------------------------------------------------------------------------------- // ----------------------------------------------------------------------------------------
// ---------------------------------------------------------------------------------------- // ----------------------------------------------------------------------------------------
// listener object // listener object
......
...@@ -13,6 +13,7 @@ ...@@ -13,6 +13,7 @@
#include <string> #include <string>
#include "../threads.h" #include "../threads.h"
#include "../smart_pointers.h" #include "../smart_pointers.h"
#include "../uintn.h"
namespace dlib namespace dlib
...@@ -129,6 +130,15 @@ namespace dlib ...@@ -129,6 +130,15 @@ namespace dlib
int shutdown ( int shutdown (
); );
// I would use SOCKET here but I don't want to include the windows
// header files since they bring in a bunch of unpleasantness. So
// I'm doing this instead which should ultimately be the same type
// as the SOCKET win the windows API.
typedef unsigned_type<void*>::type socket_descriptor_type;
socket_descriptor_type get_socket_descriptor (
) const;
private: private:
bool sd_called ( bool sd_called (
......
...@@ -177,6 +177,11 @@ namespace dlib ...@@ -177,6 +177,11 @@ namespace dlib
return temp; return temp;
} }
typedef int socket_descriptor_type;
socket_descriptor_type get_socket_descriptor (
) const { return connection_socket; }
private: private:
......
...@@ -331,6 +331,20 @@ namespace dlib ...@@ -331,6 +331,20 @@ namespace dlib
- returns OTHER_ERROR if there was an error - returns OTHER_ERROR if there was an error
!*/ !*/
typedef platform_specific_type socket_descriptor_type;
socket_descriptor_type get_socket_descriptor (
) const;
/*!
ensures
- returns the underlying socket descriptor for this connection
object. The reason you might want access to this is to
pass it to some other library that requires a socket file
descriptor. However, if you do this then you probably shouldn't
use the dlib::connection read() and write() anymore since
whatever you are doing with the socket descriptor is probably
doing I/O with the socket.
!*/
private: private:
// restricted functions // restricted functions
connection(); connection();
......
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