-#ifdef USE_SELECT
- std::map<int,int>::iterator t = fds.find(fd);
- if (t != fds.end())
- {
- fds.erase(t);
- log(DEBUG,"Deleted fd %d",fd);
- }
-#endif
-#ifdef USE_KQUEUE
- struct kevent ke;
- EV_SET(&ke, fd, ref[fd] & X_READBIT ? EVFILT_READ : EVFILT_WRITE, EV_DELETE, 0, 0, NULL);
- int i = kevent(EngineHandle, &ke, 1, 0, 0, NULL);
- if (i == -1)
+int SocketEngine::RecvFrom(EventHandler* fd, void *buf, size_t len, int flags, sockaddr *from, socklen_t *fromlen)
+{
+ int nbRecvd = recvfrom(fd->GetFd(), (char*)buf, len, flags, from, fromlen);
+ stats.UpdateReadCounters(nbRecvd);
+ return nbRecvd;
+}
+
+int SocketEngine::Send(EventHandler* fd, const void *buf, size_t len, int flags)
+{
+ int nbSent = send(fd->GetFd(), (const char*)buf, len, flags);
+ stats.UpdateWriteCounters(nbSent);
+ return nbSent;
+}
+
+int SocketEngine::Recv(EventHandler* fd, void *buf, size_t len, int flags)
+{
+ int nbRecvd = recv(fd->GetFd(), (char*)buf, len, flags);
+ stats.UpdateReadCounters(nbRecvd);
+ return nbRecvd;
+}
+
+int SocketEngine::SendTo(EventHandler* fd, const void* buf, size_t len, int flags, const irc::sockets::sockaddrs& address)
+{
+ int nbSent = sendto(fd->GetFd(), (const char*)buf, len, flags, &address.sa, address.sa_size());
+ stats.UpdateWriteCounters(nbSent);
+ return nbSent;
+}
+
+int SocketEngine::WriteV(EventHandler* fd, const IOVector* iovec, int count)
+{
+ int sent = writev(fd->GetFd(), iovec, count);
+ stats.UpdateWriteCounters(sent);
+ return sent;
+}
+
+#ifdef _WIN32
+int SocketEngine::WriteV(EventHandler* fd, const iovec* iovec, int count)
+{
+ // On Windows the fields in iovec are not in the order required by the Winsock API; IOVector has
+ // the fields in the correct order.
+ // Create temporary IOVectors from the iovecs and pass them to the WriteV() method that accepts the
+ // platform's native struct.
+ IOVector wiovec[128];
+ count = std::min(count, static_cast<int>(sizeof(wiovec) / sizeof(IOVector)));
+
+ for (int i = 0; i < count; i++)