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

test

parent 09c53f34
Loading
Loading
Loading
Loading
+8 −3
Original line number Diff line number Diff line
@@ -101,6 +101,7 @@ netplus::tcp::tcp() : socket() {
    ((struct addrinfo*)_SocketInfo)->ai_family=AF_UNSPEC;
    _Socket=-1;
    _Type=sockettype::TCP;
    _Maxconnections = 1024;
}

netplus::tcp::tcp(SOCKET sock) : socket() {
@@ -215,19 +216,23 @@ size_t netplus::tcp::recvData(void* data, unsigned long size,int flags){
    }
    return (size_t)recvsize;
}
#include <iostream>
void netplus::tcp::connect(socket *ssock){
    NetException exception;

    copyAddrInfo(&_SocketInfo,ssock->_SocketInfo);

    if( (_Socket=::socket(((struct addrinfo*)_SocketInfo)->ai_family,SOCK_STREAM,0) ) < 0 ){
    std::cout << ((struct addrinfo*)_SocketInfo)->ai_socktype << std::endl;

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

    if ( ::connect(_Socket, ((struct addrinfo*)ssock->_SocketInfo)->ai_addr, 
        (int)((struct addrinfo*)ssock->_SocketInfo)->ai_addrlen) < 0) {
    if ( ::WSAConnect(_Socket, ((struct addrinfo*)ssock->_SocketInfo)->ai_addr, 
        (int)((struct addrinfo*)ssock->_SocketInfo)->ai_addrlen,nullptr,nullptr,nullptr,nullptr) < 0) {
        exception[NetException::Error] << "Socket connect: can't connect to server aborting " << " ErrorMsg:" << GetLastError();
        throw exception;
    }