as stated in other threads, connect() might take some time to actually establish the connection. In the meanwhile, the TCP stack keeps trying, but the connect() function can not succeed immediately, thus the erro code. Later on, you'll get an event that now the connection is established.
Please read carefully this whole thread again, I already tried to explain what's going on.
