- i=0;
- i=setsockopt(s,SOL_SOCKET,SO_KEEPALIVE,(char *)&i,sizeof(i));
- if (i < 0) { perror("keepalive"); return(0); }
-
- if (connect(s,(struct sockaddr *)&them,sizeof(them)) == -1)
- { close(s); perror("connect"); return(0); }
- *sock=s;
- return(1);
- }
-
-int nbio_sock_error(sock)
-int sock;
- {
- int j,i,size;
-
- size=sizeof(int);
- i=getsockopt(sock,SOL_SOCKET,SO_ERROR,(char *)&j,&size);
- if (i < 0)
- return(1);
- else
- return(j);
- }
-
-int nbio_init_client_ip(sock, ip, port)
-int *sock;
-unsigned char ip[4];
-int port;
- {
- unsigned long addr;
- struct sockaddr_in them;
- int s,i;
-
- if (!sock_init()) return(0);
-
- memset((char *)&them,0,sizeof(them));
- them.sin_family=AF_INET;
- them.sin_port=htons((unsigned short)port);
- addr= (unsigned long)
- ((unsigned long)ip[0]<<24L)|
- ((unsigned long)ip[1]<<16L)|
- ((unsigned long)ip[2]<< 8L)|
- ((unsigned long)ip[3]);
- them.sin_addr.s_addr=htonl(addr);
-
- if (*sock <= 0)