+ return ret;
+}
+
+int SocketEngine::Shutdown(EventHandler* fd, int how)
+{
+ return shutdown(fd->GetFd(), how);
+}
+
+int SocketEngine::Bind(int fd, const irc::sockets::sockaddrs& addr)
+{
+ return bind(fd, &addr.sa, addr.sa_size());
+}
+
+int SocketEngine::Listen(int sockfd, int backlog)
+{
+ return listen(sockfd, backlog);
+}
+
+int SocketEngine::Shutdown(int fd, int how)
+{
+ return shutdown(fd, how);
+}
+
+void SocketEngine::Statistics::Update(size_t len_in, size_t len_out)
+{
+ CheckFlush();
+ indata += len_in;
+ outdata += len_out;
+}
+
+void SocketEngine::Statistics::CheckFlush() const
+{
+ // Reset the in/out byte counters if it has been more than a second
+ time_t now = ServerInstance->Time();
+ if (lastempty != now)
+ {
+ lastempty = now;
+ indata = outdata = 0;
+ }
+}
+
+void SocketEngine::Statistics::GetBandwidth(float& kbitpersec_in, float& kbitpersec_out, float& kbitpersec_total) const
+{
+ CheckFlush();
+ float in_kbit = indata * 8;
+ float out_kbit = outdata * 8;
+ kbitpersec_total = ((in_kbit + out_kbit) / 1024);
+ kbitpersec_in = in_kbit / 1024;
+ kbitpersec_out = out_kbit / 1024;
+}
+
+std::string SocketEngine::LastError()
+{
+#ifndef _WIN32
+ return strerror(errno);
+#else
+ char szErrorString[500];
+ DWORD dwErrorCode = WSAGetLastError();
+ if (FormatMessageA(FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS, NULL, dwErrorCode, MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), (LPSTR)szErrorString, _countof(szErrorString), NULL) == 0)
+ sprintf_s(szErrorString, _countof(szErrorString), "Error code: %u", dwErrorCode);
+ return szErrorString;