i am trying to create a tcp connection between two vxworks systems. One system acts as server and other as client. My requirement is i don't want to wait for server to boot first and then knowingly i try the connect call.
My client should be able to call the connect api and if the server is not up yet ....it should wait till it boots up......
i tried changing my client socket to non-blocking and try connect. Then i use select to wait for atleat two minutes. here is the code snippet (not the actual but enough to explain what i am trying) :

int res, valopt;
struct sockaddr_in addr;
long arg;
fd_set myset;
struct timeval tv;
socklen_t lon;
// Create socket
soc = socket(AF_INET, SOCK_STREAM, 0);

// Set to non-blocking
arg =1;
ioctl(soc , FIONBIO,(char *) &arg); //this part is working as i checked the returned value

// Trying to connect with timeout
addr.sin_family = AF_INET;
addr.sin_port = htons(2000);
addr.sin_addr.s_addr = inet_addr("192.168.0.11");

res = connect(soc, (struct sockaddr *)&addr, sizeof(addr));

if (res < 0) {
if (errno == EINPROGRESS) //this value is coming true
{
tv.tv_sec = 120;
tv.tv_usec = 0;
FD_ZERO(&myset);
FD_SET(soc, &myset);
if (select(soc+1, NULL, &myset, NULL, &tv) > 0)
{
lon = sizeof(int);
//now here it should come only if write fd becomes available.
//but it is reaching here even if my server is not up
//and gives error as ECONNREFUSED

getsockopt(soc, SOL_SOCKET, SO_ERROR, (void*)(&valopt), &lon);
if (valopt) {
fprintf(stderr, "Error in connection() %d - %s\n", valopt, strerror(valopt));
//it reaches here and returns wothout connecting
return;
}
}
else {
fprintf(stderr, "Timeout or error() %d - %s\n", valopt, strerror(valopt));
return;
}
}
else {
fprintf(stderr, "Error connecting %d - %s\n", errno, strerror(errno));
exit(0);
}
}
// Set to blocking mode again...
arg = 0;
ioctl(soc , FIONBIO,(char *) &arg);



somebody please help....how do i get this fixed