Lichtso / netLink

Socket and Networking Library using msgpack.org[C++11]
GNU General Public License v3.0
216 stars 48 forks source link

SocketManager::listen return an exit status code... #18

Closed DJuego closed 7 years ago

DJuego commented 8 years ago

Hi Lichtso. ;-)

I wanted to ask you about the possibility that SocketManager::listed return a exit status code, or at least, a boolean with true or false if the timeout has expired or not.

I thought about this proposal while I tried to solve the next problem;


I am working with the LEGO MindStorms EV3 bricks and the official firmware. In this case I only 'control' one side of the connection [Would this reason be the cause of the problem?]. I am using raw data.

In this context I have detected an anomaly with "SocketManager::listen". The socket is a TCP_CLIENT.

The "listen" does not "wait", and it does not invoke an event ( onReceiveRaw, onStatusChange) Neither throw an exception away. I am without clues. :-(

In order to get more details perhaps i need debug the netlink library for my very specific use case. :-/ Perhaps later on I make it. However i can not use breakpoints why the problem disappears.

The "workaround" most simple i have found for my problem is to add an active wait BEFORE the SocketManager::listen

std::size_t recibirTimeOut(std::shared_ptr<netLink::Socket> psocket, char *m_recepcion, const std::size_t tamanomaximorecepcion)
{
    std::size_t recibidotcp = 0;
    netLink::SocketManager socketManager;
    socketManager.sockets.insert(psocket); //<-is this legal? it works but...

    socketManager.onReceiveRaw = [m_recepcion, &recibidotcp, tamanomaximorecepcion](netLink::SocketManager* manager, std::shared_ptr<netLink::Socket> socket)
    {
        recibidotcp = socket->sgetn(m_recepcion, tamanomaximorecepcion);
    };

//A -one second- active wait ... Why?
    std::chrono::high_resolution_clock::time_point end, start;
    std::chrono::seconds ms;
    start = std::chrono::high_resolution_clock::now();
    do
    {
        end = std::chrono::high_resolution_clock::now();
        ms = std::chrono::duration_cast<std::chrono::seconds>(end - start);
    }
    while (ms.count() < 1);
//end of active wait

   socketManager.listen(5.0);
   return recibidotcp;
}
Lichtso commented 8 years ago

Yes I can let SocketManager::listen() return the number of seconds left to wait

but I am a bit confused about you problem. Have you measured the time spend in listen()? Which operating system is it running on? When is recibirTimeOut called and what for?

Note: socketManager.sockets.insert(psocket); //<-is this legal? it works but... should be fine, socket manager does exactly the same internally

DJuego commented 8 years ago

A fast response:

Have you measured the time spend in listen()? No. If you think it is important i can give you that measure tomorrow. It is fast. Maybe less than a second with a five seconds timeout. Admit I don´t know if it is inmediate.

Which operating system is it running on? Windows 10 x64 (Visual Studio 2015 builds and MinGW builds) Firmware Brick EV3 sources can be find in https://github.com/mindboards/ev3sources

When is recibirTimeOut called and what for?

I refuse to overwhelm you with the details. ;-) Briefly: recibirTimeOut is a function for data reception with timeout. It is used for waiting replies without blocking in a "dialog" PC-EV3. For example;

int ConexionEV3_netlink::conectarSocket()
{
    std::string envio;
    std::size_t tcpbytesenviados;
    std::size_t tcpbytesrecibidos;

        m_socketTCP = m_managerconexion.newSocket();
    m_socketTCP->initAsTcpClient(obtenerIP(), obtenerPuertoTCP(), true);

    envio.clear();
    envio.append("GET /target?sn=");
    envio.append(m_numerodeserie);
    envio.append(" VMTP1.0 Protocol: ");
    envio.append(m_protocolo);
    strcpy((char *)m_envioEV3, envio.c_str());

    tcpbytesenviados = m_socketTCP->send(m_envioEV3, envio.length());   
    tcpbytesrecibidos = recibirTimeOut(m_socketTCP, m_recepcionEV3, TAMANO_MAXIMO_RESPUESTA_PAQUETE_EV3);
    m_recepcionEV3[tcpbytesrecibidos] = '\0';
    if (strcmp((char *)m_recepcionEV3, "Accept:EV340\r\n\r\n") != 0)
    {   
                //ERROR IN CONNECTION   
        return -1;
    }   

    return 0;
}

The explanation for this code can be found in [http://www.monobrick.dk/guides/how-to-establish-a-wifi-connection-with-the-ev3-brick/], Of course I am conscious that other events like the disconnection of the socket can happen in the "listening". They are not contemplated in this function yet.

It is possible that the problem is not in your code or in my code. Perhaps the 'problem' is in the EV3 firmware, the "wifi" code part.

In any case, sincerely i think It is difficult to debug for you without a EV3 brick. Perhaps later I recreate the problem in other case, i can share with you with a minimal example.

DJuego

Lichtso commented 8 years ago

SocketManager::listen() now returns the seconds remaining (Input interval - time spent). You could use that to compare it against your measurement of the time spent.

If the call returns immediately and the return value equals the input interval that means there is no open or initialized socket to wait for (could be caused by a failed socket setup).

DJuego commented 8 years ago

Thank you for your swift reaction!

I have tried the new SocketManager::listen with a 5.0 timeout. Windows 10 in Debug Mode. Two situations

1) Do not work.

double secondsremaining= socketManager.listen(TIMEOUT);

OUTPUT: seconds remaining: 5.0000000000000000 bytes received = 0

2) Works!


std::chrono::high_resolution_clock::time_point end, start;
std::chrono::seconds ms;

start = std::chrono::high_resolution_clock::now();
do
{
    end = std::chrono::high_resolution_clock::now();
    ms = std::chrono::duration_cast<std::chrono::seconds>(end - start);
} while (ms.count() < 1);

double secondsremaining= socketManager.listen(TIMEOUT);

OUTPUT: seconds remaining: 5.0000000000000000 <------------WHY??? bytes received = 16

I have test the one-second WAIT in different localizations and i have discovered that the key is in the one-second WAIT located immediately afterward of the send operation:

tcpbytesenviados = m_socketTCP->send(m_envioEV3, envio.length());   

std::chrono::high_resolution_clock::time_point end, start;
std::chrono::seconds ms;

start = std::chrono::high_resolution_clock::now();
do
{
    end = std::chrono::high_resolution_clock::now();
    ms = std::chrono::duration_cast<std::chrono::seconds>(end - start);
} while (ms.count() < 1);

tcpbytesrecibidos = recibirTimeOut(m_socketTCP, m_recepcionEV3, TAMANO_MAXIMO_RESPUESTA_PAQUETE_EV3);

For the moment this unexplainable solution is suitable for me.

Lichtso commented 8 years ago

Found another idea here: http://stackoverflow.com/questions/14496204/select-does-not-wait-for-timeout-value-in-c-sockets

The problem is that probing for write ability causes it to return immediately. I'll try some things out, maybe splitting the select call for read / write isn't such a bad idea.

DJuego commented 8 years ago

Oh. I changed to:

m_socketTCP->initAsTcpClient(obtenerIP(), obtenerPuertoTCP(), true);
m_socketTCP->setBlockingMode(true);

The same result that the previous post. :-|

On the other hand, in the documentation you get:

  /*! Updates the blocking mode of the socket.
         A socket will be non blocking by default.
       *Try to avoid using blocking mode. Use a SocketManager with listen(sec > 0.0) instead.*
         */
        void setBlockingMode(bool blocking);

Reading this, I thought i avoid the blocking mode using listen(sec>0.0) (-"listen" always wait-). Maybe you need rephrasing this... ?

Thanks Lichtso.

DJuego

Lichtso commented 8 years ago

No you are right, we should not use the BlockingMode. I pushed a commit which tries to fix the listen method to wait for incoming data. I haven't tested it on windows, so it might have some compiler errors.

DJuego commented 8 years ago

Yes. There are compiler errors. :-P (Visual Studio 2015 - Windows 10 x64)

p:\Compilados\x32-x64>bash MSVC2015_netlink_x32_x64.sh INSTALAR x64
Instalacion netlink
-- The C compiler identification is MSVC 19.0.24213.1
-- The CXX compiler identification is MSVC 19.0.24213.1
-- Check for working C compiler: C:/Program Files (x86)/Microsoft Visual Studio 14.0/VC/bin/amd64/cl.exe
-- Check for working C compiler: C:/Program Files (x86)/Microsoft Visual Studio 14.0/VC/bin/amd64/cl.exe -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working CXX compiler: C:/Program Files (x86)/Microsoft Visual Studio 14.0/VC/bin/amd64/cl.exe
-- Check for working CXX compiler: C:/Program Files (x86)/Microsoft Visual Studio 14.0/VC/bin/amd64/cl.exe -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Configuring done
-- Generating done
-- Build files have been written to: P:/Compilados/x32-x64/TRABAJO_MSVC2015_x64/netlink/builds/debug

Microsoft (R) Program Maintenance Utility Version 14.00.24210.0
Copyright (C) Microsoft Corporation.  All rights reserved.

Scanning dependencies of target shared
[  7%] Building CXX object CMakeFiles/shared.dir/src/MsgPack.cpp.obj
MsgPack.cpp
P:\Compilados\x32-x64\TRABAJO_MSVC2015_x64\netlink\src\MsgPack.cpp(158): warning C4800: 'const uint8_t': forcing value to bool 'true' or 'false' (performance warning)
P:\Compilados\x32-x64\TRABAJO_MSVC2015_x64\netlink\src\MsgPack.cpp(284): warning C4305: '=': truncation from 'MsgPack::Type' to 'char'
P:\Compilados\x32-x64\TRABAJO_MSVC2015_x64\netlink\src\MsgPack.cpp(284): warning C4309: '=': truncation of constant value
P:\Compilados\x32-x64\TRABAJO_MSVC2015_x64\netlink\src\MsgPack.cpp(287): warning C4305: '=': truncation from 'MsgPack::Type' to 'char'
P:\Compilados\x32-x64\TRABAJO_MSVC2015_x64\netlink\src\MsgPack.cpp(287): warning C4309: '=': truncation of constant value
P:\Compilados\x32-x64\TRABAJO_MSVC2015_x64\netlink\src\MsgPack.cpp(290): warning C4305: '=': truncation from 'MsgPack::Type' to 'char'
P:\Compilados\x32-x64\TRABAJO_MSVC2015_x64\netlink\src\MsgPack.cpp(290): warning C4309: '=': truncation of constant value
P:\Compilados\x32-x64\TRABAJO_MSVC2015_x64\netlink\src\MsgPack.cpp(351): warning C4305: '=': truncation from 'MsgPack::Type' to 'char'
P:\Compilados\x32-x64\TRABAJO_MSVC2015_x64\netlink\src\MsgPack.cpp(351): warning C4309: '=': truncation of constant value
P:\Compilados\x32-x64\TRABAJO_MSVC2015_x64\netlink\src\MsgPack.cpp(354): warning C4305: '=': truncation from 'MsgPack::Type' to 'char'
P:\Compilados\x32-x64\TRABAJO_MSVC2015_x64\netlink\src\MsgPack.cpp(354): warning C4309: '=': truncation of constant value
P:\Compilados\x32-x64\TRABAJO_MSVC2015_x64\netlink\src\MsgPack.cpp(357): warning C4305: '=': truncation from 'MsgPack::Type' to 'char'
P:\Compilados\x32-x64\TRABAJO_MSVC2015_x64\netlink\src\MsgPack.cpp(357): warning C4309: '=': truncation of constant value
P:\Compilados\x32-x64\TRABAJO_MSVC2015_x64\netlink\src\MsgPack.cpp(360): warning C4305: '=': truncation from 'MsgPack::Type' to 'char'
P:\Compilados\x32-x64\TRABAJO_MSVC2015_x64\netlink\src\MsgPack.cpp(360): warning C4309: '=': truncation of constant value
P:\Compilados\x32-x64\TRABAJO_MSVC2015_x64\netlink\src\MsgPack.cpp(363): warning C4305: '=': truncation from 'MsgPack::Type' to 'char'
P:\Compilados\x32-x64\TRABAJO_MSVC2015_x64\netlink\src\MsgPack.cpp(363): warning C4309: '=': truncation of constant value
P:\Compilados\x32-x64\TRABAJO_MSVC2015_x64\netlink\src\MsgPack.cpp(367): warning C4305: '=': truncation from 'MsgPack::Type' to 'char'
P:\Compilados\x32-x64\TRABAJO_MSVC2015_x64\netlink\src\MsgPack.cpp(367): warning C4309: '=': truncation of constant value
P:\Compilados\x32-x64\TRABAJO_MSVC2015_x64\netlink\src\MsgPack.cpp(370): warning C4305: '=': truncation from 'MsgPack::Type' to 'char'
P:\Compilados\x32-x64\TRABAJO_MSVC2015_x64\netlink\src\MsgPack.cpp(370): warning C4309: '=': truncation of constant value
P:\Compilados\x32-x64\TRABAJO_MSVC2015_x64\netlink\src\MsgPack.cpp(373): warning C4305: '=': truncation from 'MsgPack::Type' to 'char'
P:\Compilados\x32-x64\TRABAJO_MSVC2015_x64\netlink\src\MsgPack.cpp(373): warning C4309: '=': truncation of constant value
P:\Compilados\x32-x64\TRABAJO_MSVC2015_x64\netlink\src\MsgPack.cpp(449): warning C4244: 'return': conversion from 'int64_t' to 'uint32_t', possible loss of data
P:\Compilados\x32-x64\TRABAJO_MSVC2015_x64\netlink\src\MsgPack.cpp(463): warning C4305: '=': truncation from 'MsgPack::Type' to 'char'
P:\Compilados\x32-x64\TRABAJO_MSVC2015_x64\netlink\src\MsgPack.cpp(463): warning C4309: '=': truncation of constant value
P:\Compilados\x32-x64\TRABAJO_MSVC2015_x64\netlink\src\MsgPack.cpp(466): warning C4305: '=': truncation from 'MsgPack::Type' to 'char'
P:\Compilados\x32-x64\TRABAJO_MSVC2015_x64\netlink\src\MsgPack.cpp(466): warning C4309: '=': truncation of constant value
P:\Compilados\x32-x64\TRABAJO_MSVC2015_x64\netlink\src\MsgPack.cpp(469): warning C4305: '=': truncation from 'MsgPack::Type' to 'char'
P:\Compilados\x32-x64\TRABAJO_MSVC2015_x64\netlink\src\MsgPack.cpp(469): warning C4309: '=': truncation of constant value
P:\Compilados\x32-x64\TRABAJO_MSVC2015_x64\netlink\src\MsgPack.cpp(479): warning C4267: 'argument': conversion from 'size_t' to 'uint32_t', possible loss of data
P:\Compilados\x32-x64\TRABAJO_MSVC2015_x64\netlink\src\MsgPack.cpp(483): warning C4267: 'argument': conversion from 'size_t' to 'uint32_t', possible loss of data
P:\Compilados\x32-x64\TRABAJO_MSVC2015_x64\netlink\src\MsgPack.cpp(553): warning C4244: '=': conversion from 'uint64_t' to 'char', possible loss of data
P:\Compilados\x32-x64\TRABAJO_MSVC2015_x64\netlink\src\MsgPack.cpp(555): warning C4305: '=': truncation from 'MsgPack::Type' to 'char'
P:\Compilados\x32-x64\TRABAJO_MSVC2015_x64\netlink\src\MsgPack.cpp(555): warning C4309: '=': truncation of constant value
P:\Compilados\x32-x64\TRABAJO_MSVC2015_x64\netlink\src\MsgPack.cpp(556): warning C4244: 'argument': conversion from 'uint64_t' to 'uint8_t', possible loss of data
P:\Compilados\x32-x64\TRABAJO_MSVC2015_x64\netlink\src\MsgPack.cpp(558): warning C4305: '=': truncation from 'MsgPack::Type' to 'char'
P:\Compilados\x32-x64\TRABAJO_MSVC2015_x64\netlink\src\MsgPack.cpp(558): warning C4309: '=': truncation of constant value
P:\Compilados\x32-x64\TRABAJO_MSVC2015_x64\netlink\src\MsgPack.cpp(559): warning C4244: 'argument': conversion from 'uint64_t' to 'uint16_t', possible loss of data
P:\Compilados\x32-x64\TRABAJO_MSVC2015_x64\netlink\src\MsgPack.cpp(561): warning C4305: '=': truncation from 'MsgPack::Type' to 'char'
P:\Compilados\x32-x64\TRABAJO_MSVC2015_x64\netlink\src\MsgPack.cpp(561): warning C4309: '=': truncation of constant value
P:\Compilados\x32-x64\TRABAJO_MSVC2015_x64\netlink\src\MsgPack.cpp(562): warning C4244: 'argument': conversion from 'uint64_t' to 'uint32_t', possible loss of data
P:\Compilados\x32-x64\TRABAJO_MSVC2015_x64\netlink\src\MsgPack.cpp(564): warning C4305: '=': truncation from 'MsgPack::Type' to 'char'
P:\Compilados\x32-x64\TRABAJO_MSVC2015_x64\netlink\src\MsgPack.cpp(564): warning C4309: '=': truncation of constant value
P:\Compilados\x32-x64\TRABAJO_MSVC2015_x64\netlink\src\MsgPack.cpp(571): warning C4244: 'argument': conversion from 'int64_t' to 'int8_t', possible loss of data
P:\Compilados\x32-x64\TRABAJO_MSVC2015_x64\netlink\src\MsgPack.cpp(573): warning C4305: '=': truncation from 'MsgPack::Type' to 'char'
P:\Compilados\x32-x64\TRABAJO_MSVC2015_x64\netlink\src\MsgPack.cpp(573): warning C4309: '=': truncation of constant value
P:\Compilados\x32-x64\TRABAJO_MSVC2015_x64\netlink\src\MsgPack.cpp(574): warning C4244: 'argument': conversion from 'int64_t' to 'int8_t', possible loss of data
P:\Compilados\x32-x64\TRABAJO_MSVC2015_x64\netlink\src\MsgPack.cpp(576): warning C4305: '=': truncation from 'MsgPack::Type' to 'char'
P:\Compilados\x32-x64\TRABAJO_MSVC2015_x64\netlink\src\MsgPack.cpp(576): warning C4309: '=': truncation of constant value
P:\Compilados\x32-x64\TRABAJO_MSVC2015_x64\netlink\src\MsgPack.cpp(577): warning C4244: 'argument': conversion from 'int64_t' to 'int16_t', possible loss of data
P:\Compilados\x32-x64\TRABAJO_MSVC2015_x64\netlink\src\MsgPack.cpp(579): warning C4305: '=': truncation from 'MsgPack::Type' to 'char'
P:\Compilados\x32-x64\TRABAJO_MSVC2015_x64\netlink\src\MsgPack.cpp(579): warning C4309: '=': truncation of constant value
P:\Compilados\x32-x64\TRABAJO_MSVC2015_x64\netlink\src\MsgPack.cpp(580): warning C4244: 'argument': conversion from 'int64_t' to 'int32_t', possible loss of data
P:\Compilados\x32-x64\TRABAJO_MSVC2015_x64\netlink\src\MsgPack.cpp(582): warning C4305: '=': truncation from 'MsgPack::Type' to 'char'
P:\Compilados\x32-x64\TRABAJO_MSVC2015_x64\netlink\src\MsgPack.cpp(582): warning C4309: '=': truncation of constant value
P:\Compilados\x32-x64\TRABAJO_MSVC2015_x64\netlink\src\MsgPack.cpp(588): warning C4305: '=': truncation from 'MsgPack::Type' to 'char'
P:\Compilados\x32-x64\TRABAJO_MSVC2015_x64\netlink\src\MsgPack.cpp(588): warning C4309: '=': truncation of constant value
P:\Compilados\x32-x64\TRABAJO_MSVC2015_x64\netlink\src\MsgPack.cpp(593): warning C4305: '=': truncation from 'MsgPack::Type' to 'char'
P:\Compilados\x32-x64\TRABAJO_MSVC2015_x64\netlink\src\MsgPack.cpp(593): warning C4309: '=': truncation of constant value
P:\Compilados\x32-x64\TRABAJO_MSVC2015_x64\netlink\src\MsgPack.cpp(732): warning C4305: '=': truncation from 'MsgPack::Type' to 'char'
P:\Compilados\x32-x64\TRABAJO_MSVC2015_x64\netlink\src\MsgPack.cpp(732): warning C4309: '=': truncation of constant value
P:\Compilados\x32-x64\TRABAJO_MSVC2015_x64\netlink\src\MsgPack.cpp(735): warning C4305: '=': truncation from 'MsgPack::Type' to 'char'
P:\Compilados\x32-x64\TRABAJO_MSVC2015_x64\netlink\src\MsgPack.cpp(735): warning C4309: '=': truncation of constant value
P:\Compilados\x32-x64\TRABAJO_MSVC2015_x64\netlink\src\MsgPack.cpp(788): warning C4305: '=': truncation from 'MsgPack::Type' to 'char'
P:\Compilados\x32-x64\TRABAJO_MSVC2015_x64\netlink\src\MsgPack.cpp(788): warning C4309: '=': truncation of constant value
P:\Compilados\x32-x64\TRABAJO_MSVC2015_x64\netlink\src\MsgPack.cpp(791): warning C4305: '=': truncation from 'MsgPack::Type' to 'char'
P:\Compilados\x32-x64\TRABAJO_MSVC2015_x64\netlink\src\MsgPack.cpp(791): warning C4309: '=': truncation of constant value
P:\Compilados\x32-x64\TRABAJO_MSVC2015_x64\netlink\src\MsgPack.cpp(841): warning C4267: 'argument': conversion from 'size_t' to 'uint32_t', possible loss of data
P:\Compilados\x32-x64\TRABAJO_MSVC2015_x64\netlink\src\MsgPack.cpp(864): warning C4267: 'initializing': conversion from 'size_t' to 'uint32_t', possible loss of data
P:\Compilados\x32-x64\TRABAJO_MSVC2015_x64\netlink\src\MsgPack.cpp(877): warning C4244: 'initializing': conversion from 'int64_t' to 'uint32_t', possible loss of data
P:\Compilados\x32-x64\TRABAJO_MSVC2015_x64\netlink\src\MsgPack.cpp(878): warning C4267: 'initializing': conversion from 'size_t' to 'uint32_t', possible loss of data
P:\Compilados\x32-x64\TRABAJO_MSVC2015_x64\netlink\src\MsgPack.cpp(895): warning C4267: 'argument': conversion from 'size_t' to 'uint32_t', possible loss of data
P:\Compilados\x32-x64\TRABAJO_MSVC2015_x64\netlink\src\MsgPack.cpp(901): warning C4267: 'argument': conversion from 'size_t' to 'uint32_t', possible loss of data
P:\Compilados\x32-x64\TRABAJO_MSVC2015_x64\netlink\src\MsgPack.cpp(944): warning C4244: 'initializing': conversion from 'int64_t' to 'uint32_t', possible loss of data
P:\Compilados\x32-x64\TRABAJO_MSVC2015_x64\netlink\src\MsgPack.cpp(945): warning C4267: 'initializing': conversion from 'size_t' to 'uint32_t', possible loss of data
P:\Compilados\x32-x64\TRABAJO_MSVC2015_x64\netlink\src\MsgPack.cpp(1029): warning C4267: 'initializing': conversion from 'size_t' to 'uint32_t', possible loss of data
P:\Compilados\x32-x64\TRABAJO_MSVC2015_x64\netlink\src\MsgPack.cpp(1168): warning C4267: 'initializing': conversion from 'size_t' to 'uint32_t', possible loss of data
[ 14%] Building CXX object CMakeFiles/shared.dir/src/Utf8.cpp.obj
Utf8.cpp
[ 21%] Building CXX object CMakeFiles/shared.dir/src/Socket.cpp.obj
Socket.cpp
P:\Compilados\x32-x64\TRABAJO_MSVC2015_x64\netlink\src\Socket.cpp(90): warning C4244: 'argument': conversion from '__int64' to 'int', possible loss of data
P:\Compilados\x32-x64\TRABAJO_MSVC2015_x64\netlink\src\Socket.cpp(100): warning C4244: 'argument': conversion from '__int64' to 'int', possible loss of data
P:\Compilados\x32-x64\TRABAJO_MSVC2015_x64\netlink\src\Socket.cpp(114): warning C4244: 'argument': conversion from '__int64' to 'int', possible loss of data
P:\Compilados\x32-x64\TRABAJO_MSVC2015_x64\netlink\src\Socket.cpp(136): warning C4101: 'err': unreferenced local variable
P:\Compilados\x32-x64\TRABAJO_MSVC2015_x64\netlink\src\Socket.cpp(147): warning C4101: 'err': unreferenced local variable
P:\Compilados\x32-x64\TRABAJO_MSVC2015_x64\netlink\src\Socket.cpp(164): warning C4101: 'err': unreferenced local variable
P:\Compilados\x32-x64\TRABAJO_MSVC2015_x64\netlink\src\Socket.cpp(195): warning C4244: '=': conversion from 'SOCKET' to 'int', possible loss of data
P:\Compilados\x32-x64\TRABAJO_MSVC2015_x64\netlink\src\Socket.cpp(238): warning C4267: 'argument': conversion from 'size_t' to 'int', possible loss of data
P:\Compilados\x32-x64\TRABAJO_MSVC2015_x64\netlink\src\Socket.cpp(247): warning C4267: 'argument': conversion from 'size_t' to 'int', possible loss of data
P:\Compilados\x32-x64\TRABAJO_MSVC2015_x64\netlink\src\Socket.cpp(258): warning C4267: 'argument': conversion from 'size_t' to 'int', possible loss of data
P:\Compilados\x32-x64\TRABAJO_MSVC2015_x64\netlink\src\Socket.cpp(351): error C2664: 'int getsockopt(SOCKET,int,int,char *,int *)': cannot convert argument 4 from 'int *' to 'char *'
P:\Compilados\x32-x64\TRABAJO_MSVC2015_x64\netlink\src\Socket.cpp(351): note: Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast
P:\Compilados\x32-x64\TRABAJO_MSVC2015_x64\netlink\src\Socket.cpp(416): warning C4244: 'argument': conversion from 'std::streamsize' to 'int', possible loss of data
P:\Compilados\x32-x64\TRABAJO_MSVC2015_x64\netlink\src\Socket.cpp(429): warning C4244: 'argument': conversion from 'std::streamsize' to 'int', possible loss of data
P:\Compilados\x32-x64\TRABAJO_MSVC2015_x64\netlink\src\Socket.cpp(455): warning C4267: 'argument': conversion from 'size_t' to 'int', possible loss of data
P:\Compilados\x32-x64\TRABAJO_MSVC2015_x64\netlink\src\Socket.cpp(469): warning C4267: 'argument': conversion from 'size_t' to 'int', possible loss of data
P:\Compilados\x32-x64\TRABAJO_MSVC2015_x64\netlink\src\Socket.cpp(495): warning C4244: 'argument': conversion from '__int64' to 'int', possible loss of data
P:\Compilados\x32-x64\TRABAJO_MSVC2015_x64\netlink\src\Socket.cpp(604): warning C4244: 'initializing': conversion from 'SOCKET' to 'int', possible loss of data
NMAKE : fatal error U1077: 'C:\PROGRA~2\MICROS~1.0\VC\bin\amd64\cl.exe' : return code '0x2'
Stop.
NMAKE : fatal error U1077: '"c:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\BIN\amd64\nmake.exe"' : return code '0x2'
Stop.
NMAKE : fatal error U1077: '"c:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\BIN\amd64\nmake.exe"' : return code '0x2'
Stop.
Lichtso commented 8 years ago

New commit 5cc5ab139df47bae70863f3418e29ce498f0b00c might fix these

DJuego commented 8 years ago

It works, Lichtso! It works! :+1: :+1: :+1: :100:
Congrats! You are clever.

Of course, intensive/exhaustive tests are necessary . It's sure that in the next days/weeks/months I will say something to you. :-D

By the way, there are an incompatibility with WINVER.

1>------ Build started: Project: wifibot_msvc2015, Configuration: Release x64 ------
1>  imgui-SFML.cpp
1>C:\Program Files (x86)\Windows Kits\8.1\Include\shared\sdkddkver.h(252): fatal error C1189: #error:  WINVER setting conflicts with _WIN32_WINNT setting
1>  imgui.cpp
1>C:\Program Files (x86)\Windows Kits\8.1\Include\shared\sdkddkver.h(252): fatal error C1189: #error:  WINVER setting conflicts with _WIN32_WINNT setting
1>  imgui_draw.cpp
1>  ConexionEV3_netlink.cpp
1>C:\Program Files (x86)\Windows Kits\8.1\Include\shared\sdkddkver.h(252): fatal error C1189: #error:  WINVER setting conflicts with _WIN32_WINNT setting
1>  ConexionPC_netlink.cpp
1>C:\Program Files (x86)\Windows Kits\8.1\Include\shared\sdkddkver.h(252): fatal error C1189: #error:  WINVER setting conflicts with _WIN32_WINNT setting
1>  Conexion_netlink.cpp
1>C:\Program Files (x86)\Windows Kits\8.1\Include\shared\sdkddkver.h(252): fatal error C1189: #error:  WINVER setting conflicts with _WIN32_WINNT setting
1>  DispositivoPC_netlink.cpp
1>C:\Program Files (x86)\Windows Kits\8.1\Include\shared\SDKDDKVer.h(252): fatal error C1189: #error:  WINVER setting conflicts with _WIN32_WINNT setting
1>  Dispositivo_netlink.cpp
1>C:\Program Files (x86)\Windows Kits\8.1\Include\shared\SDKDDKVer.h(252): fatal error C1189: #error:  WINVER setting conflicts with _WIN32_WINNT setting
1>  main.cpp
1>C:\Program Files (x86)\Windows Kits\8.1\Include\shared\sdkddkver.h(252): fatal error C1189: #error:  WINVER setting conflicts with _WIN32_WINNT setting
1>  ManagerNetwork_netlink.cpp
1>C:\Program Files (x86)\Windows Kits\8.1\Include\shared\sdkddkver.h(252): fatal error C1189: #error:  WINVER setting conflicts with _WIN32_WINNT setting
1>  Principal.cpp
1>C:\Program Files (x86)\Windows Kits\8.1\Include\shared\sdkddkver.h(252): fatal error C1189: #error:  WINVER setting conflicts with _WIN32_WINNT setting
1>  Utilidades.cpp
1>  Utilidades_netlink.cpp
1>C:\Program Files (x86)\Windows Kits\8.1\Include\shared\SDKDDKVer.h(252): fatal error C1189: #error:  WINVER setting conflicts with _WIN32_WINNT setting
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========

Currently, i have to modify the Core.h file for building in VS2015. Yes. It is a mess. :-(((


#include "MsgPack.h"

//#ifdef WINVER
#include <SDKDDKVer.h>
#include <Ws2tcpip.h>
#pragma comment(lib, "Ws2_32.lib")
#undef min
#undef max
//#else
//#include <arpa/inet.h>
//#include <sys/fcntl.h>
//#include <netdb.h>
//#include <sys/ioctl.h>
//#include <unistd.h>
//#endif
Lichtso commented 8 years ago

You could try two things: #define _WIN32_WINNT WINVER or #undef _WIN32_WINNT

But I am not too sure about the functionality of these macros: https://msdn.microsoft.com/en-gb/library/6sehtctf.aspx