UDP Binding Function Not Working When Adding Protobuf Header File

Viewed 12

I am trying to have a connection between two C++ programs using UDP but I want to do it using serializing/deserializing methods from Google Protocol Buffers. It works perfectly until I included the Protobuf header file. In the server side I have the following binding function:

if (bind(in, (sockaddr*)&serverHint, sizeof(serverHint)) == SOCKET_ERROR)
{
    cout << "Can't bind socket! " << WSAGetLastError() << endl;
    return;
}

As soon as I add: #include "VehicleExample.pb.h"

It fails to build with:

> error C2678: binary '==': no operator found which takes a left-hand operand of type 'std::_Binder<std::_Unforced,SOCKET &,sockaddr *,unsigned int>' (or there is no acceptable conversion)
1>C:\Program Files (x86)\Windows Kits\10\Include\10.0.19041.0\shared\guiddef.h(192,15): message : could be 'bool operator ==(const GUID &,const GUID &)'
1>C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.33.31629\include\thread(244,24): message : or       'bool std::operator ==(std::thread::id,std::thread::id) noexcept'
> message : while trying to match the argument list '(std::_Binder<std::_Unforced,SOCKET &,sockaddr *,unsigned int>, int)'

PS: The "VehicleExample.pb.h" file is also included on the client side and with no errors.

In case, this is the proto file I'm using:

syntax = "proto3";

package example;

message Data {
    string date = 1;
    string time = 2;
    int32 speed = 3;
    BatteryLevel battery = 4;
    AirBagStatus airbags = 5;

    Wheel FRTire = 6;
    Wheel FLTire = 7;
    Wheel BRTire = 8;
    Wheel BLTire = 9;

}

enum BatteryLevel {
UNKNOWN_LEVEL = 0;
LOW = 1;
MEDIUM = 2;
HIGH = 3;
FULL = 4;
}

enum AirBagStatus {
    UNKNOWN_STATUS = 0;
    TURNED_OFF = 1;
    TURNED_ON = 2;
}

enum Wheel {
    UNKNOWN_PRESSURE = 0;
    NON_DRIVABLE = 1;
    NEEDS_AIR = 2;
    GOOD_CONDITION = 3;
}
0 Answers
Related