0
Comment écrire du code qui spécifie le délai d'attente aux sockets BSD connect
syscall? J'écris l'application iPhone et j'ai besoin d'attendre longtemps pour obtenir une réponse de connect
syscall. Des exemples? Mercibsd sockets connect timeout iPhone
Maintenant, j'ai quelque chose comme ceci:
host_name = NULL ;
host_name = gethostbyname([[host_value hostname] UTF8String]) ;
if (host_name != NULL)
{
struct sockaddr_in sin;
sock = socket(AF_INET, SOCK_STREAM, 0);
sin.sin_family = AF_INET;
sin.sin_port = htons([[host_value port_number] intValue]);
memcpy((char *)&sin.sin_addr,(char*)host_name->h_addr,host_name->h_length);
if (connect(sock, (struct sockaddr*)(&sin),sizeof(struct sockaddr_in)) != 0)
{
/* code */
}
}
Pourquoi ne pas utiliser NSStreams? – Jasarien