void SessionUDP::DoAsyncRecv() { #ifdef VHWD_WINDOWS TempPtrT<MyOverLappedEx> q=lkfq_recv.getq(); if(!q) { return; } MyOverLappedEx &idat(*q); int bRet=WSARecvFrom(sk_local.sock, &idat.dbuf[0], idat.dbuf[1].buf?2:1, &idat.size, &iocp_flag_recv, idat.peer, idat.peer, &idat.olap, NULL); if(bRet!=0 && WSAGetLastError()!=WSA_IO_PENDING) { --m_nPendingRecv; Disconnect(); return; } else { q.release(); } #else ep_ctl(EPOLLIN); #endif }
void SessionUDP::DoAsyncSend() { #ifdef VHWD_WINDOWS TempPtrT<MyOverLappedEx> q=lkfq_send.getq(); if(!q) { return; } MyOverLappedEx &idat(*q); int bRet=WSASendTo(sk_local.sock, &idat.dbuf[0], idat.dbuf[1].buf?2:1, &idat.size, 0, idat.peer, idat.peer.v4size(), &idat.olap, NULL); if(bRet!=0 && WSAGetLastError()!=WSA_IO_PENDING) { System::CheckError("WSASend Error"); Disconnect(); --m_nPendingSend; return; } else { q.release(); } #else ep_ctl(EPOLLOUT); #endif }
// [WARNING] Linux specific: // Unlike the Mac OS version, this function change the bitmask filter for a filedescriptor value ep_mod(value epfd, value fd, value flags) { return ep_ctl(epfd, EPOLL_CTL_MOD, fd, flags); }
// [WARNING] Linux specific: // This function remove the filedescriptor from the epoll descriptor // Unlike the Mac OS version, the third argument is unused value ep_del(value epfd, value fd, value unused) { return ep_ctl(epfd, EPOLL_CTL_DEL, fd, 0); }
value ep_add(value epfd, value fd, value flags) { return ep_ctl(epfd, EPOLL_CTL_ADD, fd, flags); }
// [WARNING] Mac OS specific: // Unlike the Linux version, this function delete a precise filter from a filedescripor // and not the filedescriptor value ep_del(value epfd, value fd, value v_flags) { return ep_ctl(epfd, EV_DELETE, fd, Int_val(v_flags)); }
value ep_add(value epfd, value fd, value v_flags) { return ep_ctl(epfd, EV_ADD | EV_ENABLE, fd, Int_val(v_flags)); }