Please always post any errors you receive. It makes finding what the problem is easier.
The prototype for connect() is
- Code: Select all
int connect(int sockfd, struct sockaddr *serv_addr, int addrlen);
You are passing a string in for the second parameter and a port number for the third parameter but this is not correct. The second parameter is a structure which has information about the address and port and the third parameter is the actual length of the address member of that structure. Generally you generate this structure using getaddrinfo() as you can see in
this bit of example code.