int ident_sock; struct sockaddr_in ident_handle; struct hostent *ident_host; ident_sock = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP); ident_handle.sin_family = AF_INET; if ((ident_host = gethostbyname("localhost")) == NULL) { std::cout << " error: cannot query ident server.\r\n"; return -1; } ident_handle.sin_addr = *((struct in_addr *)ident_host->h_addr); ident_handle.sin_port = htons(113); memset(&(ident_handle.sin_zero), '\0', 8); if (connect(ident_sock, (struct sockaddr *)&ident_handle, sizeof(struct sockaddr)) == -1) { std::cout << "error: cannot create ident socket.\r\n"; close(ident_sock); return -1; } //code here