struct connection_t
{
public:
bool valid; //< true if this structure is valid
bool server; //< true if is server, otherwise is client
int socket; //< socket in use
int socketType; //< one of SOCK_STREAM or SOCK_DGRAM
struct sockaddr_in sock_from;
int sock_fromlen;
connection_t() :
valid(false),
server(false),
socket(0),
socketType(0),
sock_fromlen(0)
{
memset(&sock_from, 0, sizeof(sock_from));
}
};
This is in a .h file. I have a corresponding .cpp file that does has a function:
1 2 3 4 5
int
server_init(int in_port,
bool in_useTCP,
bool in_nonBlocking,
connection_t& out_connection)
I have had this happen with another struct of the same format. If I remove the structure variable on the left side, it is functional. It just seems to be setting equal to those structure elements. Is there something I am doing wrong? I am initialising the variable going into the function.
Okay so if that's not the problem.... are you sure sockaddr_in is a POD struct? Does it contain any complex types like string or vector or any other classes?