/*
*/
-#ifndef __SFJP_ROAST__windows__net__socket_windows_impl_HPP__
-#define __SFJP_ROAST__windows__net__socket_windows_impl_HPP__
+#ifndef __SFJP_ROAST__windows__net__socket_impl_HPP__
+#define __SFJP_ROAST__windows__net__socket_impl_HPP__
#include <string>
#include <ws2tcpip.h>
return msg;
}
- void lasterr_assert(const char* msg){
- if ( ::WSAGetLastError() != 0 )
- throw socket_exception(code, ::std::string(msg) + ' ' + get_last_error_msg());
- }
void nozero_assert(int code, const char* msg){
if ( code != 0 )
throw socket_exception(code, ::std::string(msg) + ' ' + get_last_error_msg());
}
+ void lasterr_assert(const char* msg){
+ nozero_assert(::WSAGetLastError(), msg);
+ }
public:
socket_impl(){}
// Implement Methods
handler_type create(const open_params_type& params){
sock_type sock = ::socket(af, type, protocol);
- lasterr_assert();
+ lasterr_assert("roast::windows::socket::create() ::socket() function was error.");
return sock;
}
handler_type open(const open_params_type& params){
"roast::windows::socket::listen() ::listen() function was error.");
}
- handler_type accept(::sockaddr* addr_out=NULL, int* len_out=NULL)
+ handler_type accept(handler_type handler, ::sockaddr* addr_out=NULL, int* len_out=NULL)
{
- ::SOCKET accepted_socket = ::accept(m_sock, addr_out, len_out);
+ ::SOCKET accepted_socket = ::accept(handler, addr_out, len_out);
nozero_assert(::WSAGetLastError(), "roast::socket::accept() ::accept() function was error.");
return accepted_socket;
}
int write(handler_type handler, const void* buf, size_t size, int flag)
{
int ret = ::send(handler, (const char*)buf, size, flag);
- lasterr_assert();
+ lasterr_assert("roast::windows::socket::write() ::send() function was error.");
return ret;
}
int read(handler_type handler, void* buf, size_t size, int flag)
{
int ret = ::recv(handler, (char*)buf, size, flag);
- lasterr_assert();
+ lasterr_assert("roast::windows::socket::read() ::recv() function was error.");
return ret;
}
};
- const socket_impl:::handler_type socket_impl::invalid_handle = INVALID_SOCKET;
-
+ const socket_impl::handler_type socket_impl::invalid_handle = INVALID_SOCKET;
+
////////////////////////////////////////////////////////////////////////////////
class socket : public socket_base
}
}
-#endif//__SFJP_ROAST__windows__net__socket_windows_impl_HPP__
+#endif//__SFJP_ROAST__windows__net__socket_impl_HPP__