Commit a2bee1c1 authored by jan.koester's avatar jan.koester
Browse files

test

parent 8f6475f1
Loading
Loading
Loading
Loading
+6 −6
Changes for src/windows/tcp.cpp: 6 added lines, 6 removed lines.
Original line number Diff line number Diff line
@@ -67,18 +67,18 @@ netplus::tcp::tcp(const std::string& addr, int port, int maxconnections, int soc
    hints.ai_addr = NULL;
    hints.ai_next = NULL;

    int tsock;

    char serv[512] = {'\0'};
    snprintf(serv,512,"%d",port);

    if ((tsock=::getaddrinfo(addr.c_str(), serv,&hints,&result)) != 0 ) {
    if (::getaddrinfo(addr.c_str(), serv,&hints,&result) != 0 ) {
        exception[NetException::Critical] << "Socket Invalid address/ Address not supported";
        throw exception;
    }

    std::cerr << result << std::endl;

    for (rp = result; rp != nullptr; rp = rp->ai_next) {
        _Socket = ::WSASocketW(rp->ai_family, rp->ai_socktype,
        _Socket = ::WSASocket(rp->ai_family, rp->ai_socktype,
                           rp->ai_protocol,nullptr, 0, sockopts);

        if (_Socket == INVALID_SOCKET)
@@ -175,7 +175,7 @@ void netplus::tcp::accept(LPFN_ACCEPTEX lpfnAcceptEx,std::unique_ptr<socket> &cs
    ((struct sockaddr_in*)((struct addrinfo*)csock->_SocketInfo)->ai_addr)->sin_port =
        ((struct sockaddr_in*)((struct addrinfo*)_SocketInfo)->ai_addr)->sin_port;

    if ((csock->_Socket = WSASocketW(((struct addrinfo*)_SocketInfo)->ai_family,
    if ((csock->_Socket = WSASocket(((struct addrinfo*)_SocketInfo)->ai_family,
         ((struct addrinfo*)_SocketInfo)->ai_socktype, 0, nullptr, 0, WSA_FLAG_OVERLAPPED)) < 0) {
        exception[NetException::Error] << "Accept create Socket faied: failed on " << (int)csock->_Socket << " error code : " << GetLastError();
        throw exception;
@@ -319,7 +319,7 @@ void netplus::tcp::connect(std::unique_ptr<socket> &csock){
    copyAddrInfo(&_SocketInfo, csock->_SocketInfo, csock->_SocketInfoLen);

    // Change this line to create an overlapped socket
    if ((_Socket = ::WSASocketW(((struct addrinfo*)_SocketInfo)->ai_family, ((struct addrinfo*)_SocketInfo)->ai_socktype,
    if ((_Socket = ::WSASocket(((struct addrinfo*)_SocketInfo)->ai_family, ((struct addrinfo*)_SocketInfo)->ai_socktype,
        ((struct addrinfo*)_SocketInfo)->ai_protocol, nullptr, 0, WSA_FLAG_OVERLAPPED)) < 0) {
        NetException exception;
        exception[NetException::Error] << "Create Socket " << (int)_Socket << " failed : " << GetLastError();
+4 −4
Changes for src/windows/udp.cpp: 4 added lines, 4 removed lines.
Original line number Diff line number Diff line
@@ -57,7 +57,7 @@ netplus::udp::udp(const std::string &addr, int port, int maxconnections, int soc
    struct addrinfo hints, * result = nullptr, * rp = nullptr;

    memset(&hints, 0, sizeof(hints));
    hints.ai_family = AF_UNSPEC;
    hints.ai_family = AF_INET;
    hints.ai_socktype = SOCK_DGRAM;
    hints.ai_flags = AI_PASSIVE;
    hints.ai_protocol = IPPROTO_UDP;
@@ -76,7 +76,7 @@ netplus::udp::udp(const std::string &addr, int port, int maxconnections, int soc
    }

    for (rp = result; rp != nullptr; rp = rp->ai_next) {
        _Socket = ::WSASocketW(rp->ai_family, rp->ai_socktype,
        _Socket = ::WSASocket(rp->ai_family, rp->ai_socktype,
            rp->ai_protocol, nullptr, 0, sockopts);
        if (_Socket == -1)
            continue;
@@ -162,7 +162,7 @@ void netplus::udp::accept(LPFN_ACCEPTEX lpfnAcceptEx, std::unique_ptr<socket> &c
    ((struct sockaddr_in*)((struct addrinfo*)csock->_SocketInfo)->ai_addr)->sin_port =
        ((struct sockaddr_in*)((struct addrinfo*)_SocketInfo)->ai_addr)->sin_port;

    if ((csock->_Socket = WSASocketW(((struct addrinfo*)_SocketInfo)->ai_family,
    if ((csock->_Socket = WSASocket(((struct addrinfo*)_SocketInfo)->ai_family,
        ((struct addrinfo*)_SocketInfo)->ai_socktype, 0, nullptr, 0, WSA_FLAG_OVERLAPPED)) < 0) {
        exception[NetException::Error] << "Accept create Socket faied: failed on " << (int)csock->_Socket << " error code : " << GetLastError();
        throw exception;
@@ -304,7 +304,7 @@ void netplus::udp::connect(std::unique_ptr<socket> &csock) {
    copyAddrInfo(&_SocketInfo, csock->_SocketInfo, csock->_SocketInfoLen);

    // Change this line to create an overlapped socket
    if ((_Socket = ::WSASocketW(((struct addrinfo*)_SocketInfo)->ai_family, ((struct addrinfo*)_SocketInfo)->ai_socktype,
    if ((_Socket = ::WSASocket(((struct addrinfo*)_SocketInfo)->ai_family, ((struct addrinfo*)_SocketInfo)->ai_socktype,
        ((struct addrinfo*)_SocketInfo)->ai_protocol, nullptr, 0, WSA_FLAG_OVERLAPPED)) < 0) {
        NetException exception;
        exception[NetException::Error] << "Create Socket " << (int)_Socket << " failed : " << GetLastError();