Question

I am making a simple call to connect(2), in a C++ program. The code is:

connect(socket_fd, (struct sockaddr *)&name, SUN_LEN(name));

(here, name is a struct sockaddr_un).

When I try to compile this, I get the following error from g++:

error: base operand of '->' has non-pointer type 'sockaddr_un'

I am totally baffled by this, because I'm not using the -> operator anywhere in the program! Is there something wrong with the way I'm taking the address of name, or the way I am casting it?

Was it helpful?

Solution

The macro SUN_LEN expects the passed structure to be a pointer, so you should use SUN_LEN(&name).

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top