Commit 509c1305 authored by Davis King's avatar Davis King

Added some requirements and asserts.

parent 84e0f0e9
...@@ -26,7 +26,16 @@ namespace dlib ...@@ -26,7 +26,16 @@ namespace dlib
const std::string& ip_, const std::string& ip_,
unsigned short port_ unsigned short port_
): ip(ip_), port(port_) ): ip(ip_), port(port_)
{} {
// make sure requires clause is not broken
DLIB_ASSERT(is_ip_address(ip) && port != 0,
"\t connect_to_ip_and_port()"
<< "\n\t Invalid inputs were given to this function"
<< "\n\t ip: " << ip
<< "\n\t port: " << port
<< "\n\t this: " << this
);
}
private: private:
friend class bridge; friend class bridge;
...@@ -38,7 +47,16 @@ namespace dlib ...@@ -38,7 +47,16 @@ namespace dlib
{ {
listen_on_port( listen_on_port(
unsigned short port_ unsigned short port_
) : port(port_) {} ) : port(port_)
{
// make sure requires clause is not broken
DLIB_ASSERT( port != 0,
"\t listen_on_port()"
<< "\n\t Invalid inputs were given to this function"
<< "\n\t port: " << port
<< "\n\t this: " << this
);
}
private: private:
friend class bridge; friend class bridge;
......
...@@ -18,6 +18,9 @@ namespace dlib ...@@ -18,6 +18,9 @@ namespace dlib
unsigned short port unsigned short port
); );
/*! /*!
requires
- is_ip_address(ip) == true
- port != 0
ensures ensures
- this object will represent a request to make a TCP connection - this object will represent a request to make a TCP connection
to the given IP address and port number. to the given IP address and port number.
...@@ -30,6 +33,8 @@ namespace dlib ...@@ -30,6 +33,8 @@ namespace dlib
unsigned short port unsigned short port
); );
/*! /*!
requires
- port != 0
ensures ensures
- this object will represent a request to listen on the given - this object will represent a request to listen on the given
port number for incoming TCP connections. port number for incoming TCP connections.
......
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