日期:2014-05-16 浏览次数:20797 次
socket_list[i].socket = socket(AF_INET,SOCK_STREAM,0);
setsockopt(socket_list[i].socket,SOL_SOCKET,SO_KEEPALIVE,&optval,sizeof(optval));
address.sin_family = AF_INET;
address.sin_addr.s_addr = netParam.srv[i].ip.s_addr;
address.sin_port = htons(netParam.srv[i].port); //(in_port_t)->(uint16_t)
len = sizeof(address);
printf("connect to srv %d\n",i);
result = connect(socket_list[i].socket,(struct sockaddr *)&address,len);
if(result == -1)
{
socket_list[i].used = 0;
socket_list[i].pass = 0;
printf("can not connected to server %d.\n",i);
}
else
{
printf("connected to server %d.\n",i);
socket_list[i].used = 1;
xml_request(i);
}