Commit 3b0c945f authored by jan.koester's avatar jan.koester
Browse files

some modes

parent e8f0bd56
Loading
Loading
Loading
Loading
+1
Changes for src/socket.h: 1 added line, 0 removed lines.
Original line number Diff line number Diff line
@@ -116,6 +116,7 @@ namespace netplus {
#ifdef Windows 
            WSAOVERLAPPED            _Overlapped;
            WSABUF                   _wsaBuf;
			bool					 _Wait;
#endif
        protected:
            void copyAddrInfo(ULONG_PTR *dest,ULONG_PTR src,size_t srclen);
+2
Changes for src/windows/socket.cpp: 2 added lines, 0 removed lines.
Original line number Diff line number Diff line
@@ -47,12 +47,14 @@ std::atomic<int> netplus::socket::_InitCount=0;
WSAData _WSAData;

netplus::socket::socket(){
    memset(&_Overlapped, 0, sizeof(_Overlapped));
    _SocketInfo=(ULONG_PTR)malloc(sizeof(struct addrinfo));
    _SocketInfoLen=sizeof(struct addrinfo);
    memset((void*)_SocketInfo,0,sizeof(struct addrinfo));
    _Extension = 0;
    _Type=-1;
    _Socket = -1;
    _Wait = false;
    _wsaBuf.buf = nullptr;
	_wsaBuf.len = 0;
    memset(&_Overlapped, 0, sizeof(WSAOVERLAPPED));
+9 −2
Changes for src/windows/tcp.cpp: 9 added lines, 2 removed lines.
Original line number Diff line number Diff line
@@ -170,8 +170,6 @@ void netplus::tcp::accept(LPFN_ACCEPTEX lpfnAcceptEx,std::shared_ptr<socket> &cs
        throw exception;
    }

    memset(&csock->_Overlapped, 0, sizeof(csock->_Overlapped));

    if (!lpfnAcceptEx(_Socket,csock->_Socket, &AcceptBuffer, 0,
        sizeof(SOCKADDR_IN6) + 16, sizeof(SOCKADDR_IN6) + 16, &dwbytes, &csock->_Overlapped)) {

@@ -207,6 +205,9 @@ size_t netplus::tcp::sendData(buffer &data,int flags){

    int rval = ::WSASend(_Socket, &_wsaBuf, 1, &dwsend, flags, &_Overlapped, nullptr);

    if (_Wait)
        WSAWaitForMultipleEvents(1, &_Overlapped.hEvent, FALSE, INFINITE, FALSE);

    NetException exception;

    if (rval == SOCKET_ERROR) {
@@ -243,6 +244,9 @@ size_t netplus::tcp::recvData(buffer &data,int flags){

    int rval = ::WSARecv(_Socket, &_wsaBuf, 1, &dwBytes, (LPDWORD)&flags, &_Overlapped, nullptr);

    if (_Wait)
        WSAWaitForMultipleEvents(1, &_Overlapped.hEvent, FALSE, INFINITE, FALSE);

    if (rval == SOCKET_ERROR) {
        switch (WSAGetLastError()) {
        case WSAEWOULDBLOCK:
@@ -292,6 +296,9 @@ void netplus::tcp::connect(std::shared_ptr<socket> &csock){
        exception[NetException::Error] << "Connect: getpeername failed on " << (int)_Socket << " error code : " << GetLastError();
        throw exception;
    }


	_Wait = true;
}


+8 −2
Changes for src/windows/udp.cpp: 8 added lines, 2 removed lines.
Original line number Diff line number Diff line
@@ -167,8 +167,6 @@ void netplus::udp::accept(LPFN_ACCEPTEX lpfnAcceptEx, std::shared_ptr<socket> &c
        throw exception;
    }

    memset(&csock->_Overlapped, 0, sizeof(csock->_Overlapped));

    if (!lpfnAcceptEx(_Socket, csock->_Socket, &AcceptBuffer, 0,
        sizeof(SOCKADDR_IN6) + 16, sizeof(SOCKADDR_IN6) + 16, &dwbytes, &csock->_Overlapped)) {

@@ -203,6 +201,9 @@ size_t netplus::udp::sendData(buffer &data, int flags) {

    int rval = ::WSASend(_Socket, &_wsaBuf, 1, &dwsend, flags, &_Overlapped, nullptr);

    if(_Wait)
        WSAWaitForMultipleEvents(1, &_Overlapped.hEvent, FALSE, INFINITE, FALSE);

    NetException exception;

    if (rval == SOCKET_ERROR) {
@@ -239,6 +240,9 @@ size_t netplus::udp::recvData(buffer &data, int flags) {

    int rval = ::WSARecv(_Socket, &_wsaBuf, 1, &dwBytes, (LPDWORD)&flags, &_Overlapped, nullptr);

    if(_Wait)
        WSAWaitForMultipleEvents(1,&_Overlapped.hEvent, FALSE, INFINITE, FALSE);

    if (rval == SOCKET_ERROR) {
        switch (WSAGetLastError()) {
        case WSAEWOULDBLOCK:
@@ -287,6 +291,8 @@ void netplus::udp::connect(std::shared_ptr<socket> &csock) {
        exception[NetException::Error] << "Connect: getpeername failed on " << (int)_Socket << " error code : " << GetLastError();
        throw exception;
    }

    _Wait = true;
}