T
T
Type Programmer2018-07-30 18:05:34
linux
Type Programmer, 2018-07-30 18:05:34

C++ TCP client, can't understand connect() function argument?

There is a small TCP client, everything is more clear in it, except for the line

connect(sockfd, (struct sockaddr *)&serv_addr, sizeof(serv_addr));

I can not understand why not just write?
connect(sockfd,serv_addr, sizeof(serv_addr));
What does it mean?
(struct sockaddr *)&serv_addr
PS: Do not judge strictly, I'm just a user who wants to understand how and what works, I could basically just remember how to write correctly and that's all, but I want to understand the code perfectly ...

Answer the question

In order to leave comments, you need to log in

2 answer(s)
S
Sergey Sakhno, 2018-07-30
@Punk_Joker

If you want to understand code perfectly then learn C++

D
Dmitry, 2018-07-30
@dmtrrr

(struct sockaddr *) - cast to pointer to struct sockaddr

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question