当前位置: 技术问答>linux和unix
如何设置Socket链接超时,在线等,一定给分!
来源: 互联网 发布时间:2014-12-02
本文导语: int connect_httpserver(char *strSrvAddress,int SrvPort) { int sock_fd,ope,len;0D struct sockaddr_in cli_sock; struct hostent *ht; int retcode; struct timeval nTimeout; struct pr...
int connect_httpserver(char *strSrvAddress,int SrvPort)
{
int sock_fd,ope,len;0D
struct sockaddr_in cli_sock;
struct hostent *ht;
int retcode;
struct timeval nTimeout;
struct protoent *protos;
protos=getprotobyname(“tcp");
if ((sock_fd = socket(PF_INET, SOCK_STREAM, protos->p_proto))
{
int sock_fd,ope,len;0D
struct sockaddr_in cli_sock;
struct hostent *ht;
int retcode;
struct timeval nTimeout;
struct protoent *protos;
protos=getprotobyname(“tcp");
if ((sock_fd = socket(PF_INET, SOCK_STREAM, protos->p_proto))