Hello bugsy, good job.
Sometimes a non-blocking socket can return EINPROGRESS at connect, so that check will fail and the socket won't be created ( but it should be created, and then checked with socket_is_writable to see when the socket is ready for sending data )
PHP Code:
if ( ( ( connect(sock, (struct sockaddr*)&server , sizeof( server ) ) ) == SOCKET_ERROR ) && ( GetSocketError() != WOULDBLOCK ) )
{
*err = GetSocketError();
return -1;
}
Joaquim's version works fine
PHP Code:
// Not, let's try to open a connection to the server
contr = connect(sock, (struct sockaddr*)&server, sizeof( server));
/*
if (contr < 0) {
// If an error occured cancel
params[4] = 3; //error while connecting
return -1;
}
*/
__________________