- UID
- 805639
|
请教一个MCF52259 MQXRTCS的问题。connect网络连接的超时时间怎么设置无效?始终在100秒才能退出connect程序(无法连接情况下)。
hNewSocket = socket(PF_INET, SOCK_STREAM, 0);
optval = 10;//480,000 (eight minutes).
error = setsockopt(hNewSocket, SOL_TCP, OPT_CONNECT_TIMEOUT, &optval, sizeof(optval));
optval = 1000;
error = setsockopt(hNewSocket, SOL_TCP, OPT_TBSIZE,&optval, sizeof(optval));
optval = 1000;
error = setsockopt(hNewSocket, SOL_TCP, OPT_RBSIZE, &optval, sizeof(optval));
raddr.sin_family = AF_INET;
raddr.sin_port = SERVER_PORT;
raddr.sin_addr.s_addr = IPADDR(192,168,0,24) ;
error = connect(hNewSocket, &raddr, sizeof(raddr));
不管OPT_CONNECT_TIMEOUT怎么设置,如果无法连接的话都要100秒才能往下执行。这个超时改时间怎么修改? |
|