I get your point, and of course I thanks you both for the advices. I'm not gonna quit my job for became a programmer, don't worry. :)
The main() is missing because is not written yet, I've decided to start to understand how it works function by function. I know that main() is needed, but even without main, using a compiler, if everything is correct you should get no syntax error at least!
The first part, actually, is more like a reminder or a note and can be ignored: it loads only the correct headers for the operative system in which is running, but I don't know if I'll keep it, because I'm planning to develope this thing only for linux. I know from different examples and educational websites (why you say is not c++ by the way?), that the function is written exactly the same in both operative system, but needs different headers. (correct me if this is wrong)
for the function, I've used this as a reference:
https://www.ibm.com/support/knowledgecenter/en/SSLTBW_2.3.0/com.ibm.zos.v2r3.bpxbd00/getopt.htm
trying to adapt it to my case, I've also read the tutorials that you posted, but I can't figure out by myself where is the problem, the structure of the function should be:
int getsockopt(int socket[the descriptor of the socket]
, int level[wich is SOL_SOCKET for me]
, int option_name[wich is SO_ERROR, because I want to know if there is a connection error]
, void *__restrict__ option_value[is where the option data will point]
, socklen_t *__restrict__ option_len[is the lenght of my option data]
);
I know I need to initialize the parameters and to specify the data type for the options, but anyway I flip it, even written as a main function, I'm always getting the error "expected ‘,’ or ‘...’ before numeric constant"
I don't get why, since SOL_SOCKET is a parameter of the function: of course is a costant, but as far as I know, it only give instructions to getsockopt on what is the level of interaction (socket, IPV4, IPV6, etc etc)!
...I believe that the information on IBM's website are correct, but maybe there is a typo?