I am trying to understand some socket code. One of the function calls is as follows:
Just wondering what the syntax for the last two arguments means and how it works.Code:msgsock = accept(sock, (struct sockaddr *)0, (int *)0);
Thanks in advance.
Printable View
I am trying to understand some socket code. One of the function calls is as follows:
Just wondering what the syntax for the last two arguments means and how it works.Code:msgsock = accept(sock, (struct sockaddr *)0, (int *)0);
Thanks in advance.
In this example, you are saying accept a connection on sock and you are not collecting any information about who that is (since the destination address for the last two arguments is 0). It might be a better practice to just use NULL here, if accept() will accept that.
The reason you might need to cast zero would be that accept() expects a pointer of some specific sort.
both are NULL pointers cast to the proper type