Here is my connection code
Where do I have to use this option?Code:int openConnection(const char *hostName, int port) { struct hostent *host; struct sockaddr_in addr; if ((host = gethostbyname(hostName)) == nullptr) { perror(hostName); abort(); } int sd = socket(PF_INET, SOCK_STREAM, 0); memset(&addr, 0, sizeof(addr)); addr.sin_family = AF_INET; addr.sin_port = htons(port); addr.sin_addr.s_addr = *(long*)(host->h_addr); if (connect(sd, (struct sockaddr *)&addr, sizeof(addr)) != 0) { closesocket(sd); perror(hostName); abort(); } return sd; }




Reply With Quote
