View Single Post
Javivi
AlliedModders Donor
Join Date: Dec 2008
Old 01-05-2012 , 10:52   Re: [INC/MODULE] Sockets Forwards
Reply With Quote #14

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 sizeofserver ) ) ) == 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*)&serversizeofserver));
    
    
/*
    if (contr < 0) {
            // If an error occured cancel
            params[4] = 3;  //error while connecting
            return -1;
    }
    */ 
__________________
Javivi is offline