Question: I want to get a flicker button , and then I code like this
I init the button like this:

```
_btn = [[UIButton alloc] initWithFrame:CGRectMake(50, 50, 200, 200)];
[_btn addTarget:self action:@selector(test:) forControlEvents:UIControlEventTouchUpInside];
[_btn setBackgroundImage:[UIImage imageNamed:@"img2.jpg"] forState:UIControlStateNormal];

```

and the I code the animation like this :

```
[UIView animateWithDuration:1 delay:0 options:UIViewAnimationOptionRepeat|UIViewAnimationOptionAutoreverse animations:^{
    _btn.alpha = 0.2;
} completion:nil];

```

The button is vague but it can not be selected , it can not receive the sender .
Anyone knows why it can not receive the sender ?

Answer: 
> 
> Setting time out for connect() function tcp socket programming in C is not working
> 
> 
> 

Correction. Setting the connect timeout *is* working. What 'isn't working' is the subsequent `recvfrom()`, and that's because you left the socket in non-blocking mode and you don't know what to do with the resulting `EAGAIN.` So, either handle that, by using `select()` to tell you when the socket is ready to read, or else put the socket back into blocking mode after finishing the connect.
The first successful select means the connect operation is complete but *does not necessarily mean it succeed*, from [connect](http://linux.die.net/man/2/connect) man page, you should check `SO_ERROR` to make sure it completed successfully

> 
> It is possible to select(2) or poll(2) for completion by selecting the
>  socket for writing. **After select(2) indicates writability, use
>  getsockopt(2) to read the SO\_ERROR option at level SOL\_SOCKET to 
>  determine whether connect() completed successfully** (SO\_ERROR is zero)
>  or unsuccessfully (SO\_ERROR is one of the usual error codes listed
>  here, explaining the reason for the failure).
> 
> 
> 

So in your code you should do something like this:

```
int ret;
ret=select(sockfd+1, NULL, &wfds, NULL, NULL); //should use timeout
if(ret==1 && getSocketOpt(sockfd, SO_ERROR) ==0) {
    return 0; //successfully connected
}

```

Then, as mentioned in the other answer you should call select again before writing or reading from the socket.