Is it ok to zero out "sockaddr_in" like this:
Instead of the usual:Code:sockaddr_in clientService = {0};
Code:sockaddr_in clientService;
memset( &clientService, 0, sizeof clientService );
Printable View
Is it ok to zero out "sockaddr_in" like this:
Instead of the usual:Code:sockaddr_in clientService = {0};
Code:sockaddr_in clientService;
memset( &clientService, 0, sizeof clientService );
yep, perfectly ok. It may not necessarilly have the effect you intend though. sockaddr_in is a structure, as such you need to zero out every member variable in it.
Thanks Abachler!
I thought this technique works the same for both arrays and structures.
In an array it zeros out every element.
It may work for your particular complilers implimentation, but afaik it is undefined behavior and may not be portable to other compilers.