Commit 9e37cf66 authored by jan.koester's avatar jan.koester
Browse files

test

parent b6ca2ae1
Loading
Loading
Loading
Loading
+2 −1
Original line number Diff line number Diff line
@@ -218,8 +218,9 @@ namespace netplus {
		}
		_Timeout = timeout;
		_ServerSocket = serversocket;
		_ServerSocket->setFlag(WSA_FLAG_OVERLAPPED);
		_ServerSocket->setFlag(1);
		_ServerSocket->bind();
		_ServerSocket->setnonblocking();
		_ServerSocket->listen();

		SYSTEM_INFO sysinfo;
+2 −4
Original line number Diff line number Diff line
@@ -99,8 +99,8 @@ netplus::tcp::tcp(const char* addr, int port,int maxconnections,int sockopts) :
    }

    for (rp = result; rp != nullptr; rp = rp->ai_next) {
        _Socket = ::socket(rp->ai_family, rp->ai_socktype,
                           rp->ai_protocol);
        _Socket = ::WSASocketW(rp->ai_family, rp->ai_socktype,
                           rp->ai_protocol,nullptr,0,sockopts);
        if (_Socket == -1)
            continue;
        copyAddrInfo(&_SocketInfo,(ULONG_PTR)rp,sizeof(hints));
@@ -110,8 +110,6 @@ netplus::tcp::tcp(const char* addr, int port,int maxconnections,int sockopts) :
    _SocketInfoLen = sizeof(hints);
    ::freeaddrinfo(result);

    int optval = 1;
    setsockopt(_Socket, SOL_SOCKET, sockopts,&optval,sizeof(optval));
    _Type=sockettype::TCP;
}

+2 −1
Original line number Diff line number Diff line
@@ -48,7 +48,8 @@ namespace netplus {
            socket();
            virtual                 ~socket();
            
            void                     setnonblocking();
            void                     setFlag(int flag);

            void                     setTimeout(int sec);
            
            virtual void             accept(socket *csock)=0;
+4 −3
Original line number Diff line number Diff line
@@ -72,8 +72,9 @@ netplus::socket::~socket(){
    free((void*)_SocketInfo);
}

void netplus::socket::setnonblocking(){
    u_long mode = 1; // 1 to enable non-blocking socket

void netplus::socket::setFlag(int flag) {
    u_long mode = flag;
    if (ioctlsocket(_Socket, FIONBIO, &mode) < 0) {
        NetException exception;
        exception[NetException::Error] << "Could not set ClientSocket nonblocking!";
+1 −1
Original line number Diff line number Diff line
@@ -231,7 +231,7 @@ void netplus::tcp::connect(socket *ssock){
        ((struct sockaddr_in*)((struct addrinfo*)ssock->_SocketInfo)->ai_addr)->sin_port;

    if( (_Socket=::WSASocketW(((struct addrinfo*)_SocketInfo)->ai_family, ((struct addrinfo*)_SocketInfo)->ai_socktype,
        ((struct addrinfo*)_SocketInfo)->ai_protocol, nullptr, 0, WSA_FLAG_OVERLAPPED)) < 0 ){
        ((struct addrinfo*)_SocketInfo)->ai_protocol, nullptr, 0, 0)) < 0 ){
        NetException exception;
        exception[NetException::Error] << "Create Socket " << (int) _Socket << " failed : " <<  GetLastError();
        throw exception;