Example #1
0
static trap_retval DoRemotePut( byte *snd, trap_elen len )
{
    WORD        rc;

putstring( "RemotePut\r\n" );
putconnstatus( Connection );
    if( len == 0 ) {
        _INITSPXECB( Send, 1, NULL, 0 );
    } else {
        _INITSPXECB( Send, 2, (char *)snd, len );
    }
    SendECB.hsem = (HSEM) &SendSem;
    SendHead.connectionCtl |= 0x10;
    SendHead.packetLen = _SWAPINT( sizeof( SendHead ) + len );
    DosSemSet( &SendSem );
    rc = SpxSendSequencedPacket( Connection, &SendECB );
    putrc( "SPXSendSequencedPacket", rc );

    for( ;; ) {
        /*
            I don't know what the 0x1001 status is - I can't find it
            in any documentation, but if we don't wait for it to clear,
            things mess up badly.
        */
        if( SendECB.status != SPX_SUCCESSFUL && !InUse( SendECB ) && SendECB.status != 0x1001 )
            break;
        rc = DosSemWait( &SendSem, 1000 );
        if( rc != ERROR_SEM_TIMEOUT ) {
            break;
        }
    }
    SendECB.hsem = 0;
putstring( "Done RemotePut\r\n" );
    return( len );
}
Example #2
0
void RemoteDisco( void )
{
    int         i;

    /* make sure last packet gets sent */
    Delay( TICKS_PER_SEC/2 );

    Listening = 0;
    _INITSPXECB( Conn, 1, 0, 0 );
    _SPXTerminateConnection( Connection, &ConnECB );
#ifdef SERVER
    _IPXCancelEvent( &ConnECB );
#endif
    for( i = NUM_REC_BUFFS - 1; i >= 0; --i ) {
        if( RecECB[i].inUseFlag ) {
            _IPXCancelEvent( &RecECB[i] );
        }
    }
    _IPXCancelEvent( &SendECB );
    _IPXDisconnectFromTarget( &SendHead.destination.network.a[0] );
    for( i = 0; i < NUM_REC_BUFFS; ++i ) {
        ZeroArray( RecHead[i] );
        ZeroArray( RecECB[i] );
    }
    ZeroArray( ConnHead );
    ZeroArray( SendHead );
    ZeroArray( ConnECB );
    ZeroArray( SendECB );
}
Example #3
0
bool RemoteConnect( void )
{
    PostListens();
#ifdef SERVER
    if( !Listening ) {
        _INITSPXECB( Conn, 1, 0, 0 );
        _SPXListenForConnection( 0, 0, &ConnECB );
        Listening = 1;
    } else if( ConnECB.inUseFlag == 0 ) {
        if( ConnECB.completionCode == 0 ) {
            Connection = ConnECB.SPXConnectionID;
            return( true );
        }
    }
    _IPXRelinquishControl();
#else
    _INITECB( SendECB, SendHead, 1, SPX );
    if( _SPXEstablishConnection( 0, 0, &Connection, &SendECB ) == 0 ) {
        if( WaitTimeout( &SendECB, MAX_CONNECT_WAIT, 0 ) ) {
            return( true );
        } else {
            _SPXAbortConnection( Connection );
        }
    }
#endif
    return( false );
}
Example #4
0
void RemoteDisco( void )
{
    int         i;

    DosSleep( 500 );    /* make sure last packet gets sent */
    Listening = 0;
    _INITSPXECB( Conn, 1, 0, 0 );
    if( SpxTerminateConnection( Connection, &ConnECB ) == 0 ) {
        while( InUse( ConnECB ) ) IPXRelinquishControl();
    }
    for( i = NUM_REC_BUFFS-1; i >= 0; --i ) {
        if( InUse( RecECB[i] ) ) {
            SpxCancelPacket( &RecECB[i] );
        }
    }
    if( InUse( SendECB ) ) {
        SpxCancelPacket( &SendECB );
    }
    for( i = NUM_REC_BUFFS-1; i >= 0; --i ) {
        ZeroArray( RecHead[i] );
        ZeroArray( RecECB[i] );
    }
    ZeroArray( ConnHead );
    ZeroArray( SendHead );
    ZeroArray( ConnECB );
    ZeroArray( SendECB );
}
Example #5
0
static trap_retval DoRemotePut( void *data, trap_elen len )
{
    _DBG_IPX(("RemotePut\r\n"));
    _INITSPXECB( Send, 2, data, len );
    SendHead.connectionControl |= 0x10;
    SendHead.length = _SWAPINT( sizeof( SendHead ) + len );
    CSPXSendSequencedPacket( Connection, &SendECB );
    while( InUse( SendECB ) )
        NothingToDo();
    return( len );
}
Example #6
0
char RemoteConnect( void )
{
    WORD        rc;
    #ifdef SERVER
        if( !Listening ) {
            _INITSPXECB( Conn, 1, 0, 0 );
            rc = SpxListenForConnection( SPXSocket, &ConnECB, 0, 0, &Connection );
            putrc( "SPXListenForConnection", rc );
            Listening = 1;
        } else if( !InUse( ConnECB ) ) {
            PostListens();
            return( 1 );
        }
        IPXRelinquishControl();
    #else
putstring( "RemoteConnect\r\n" );
        _INITSPXECB( Send, 1, NULL, 0 );
        if( ( rc = SpxEstablishConnection( SPXSocket, &SendECB,
                                    0, 0x10, &Connection ) ) == 0 ) {
            int i;

            for( i = 1; i < 20; ++i ) {
putstring( "RemoteConnect loop\r\n" );
                if( !InUse( SendECB ) ) {
                    PostListens();
putstring( "RemoteConnect loop done\r\n" );
                    return( 1 );
                }
                DosSleep( 100 );        /* 20 * 100 is approx 2 seconds */
            }
putstring( "RemoteConnect aborting\r\n" );
            rc = SpxAbortConnection( Connection );
            putrc( "SPXAbortConnection", rc );
        } else {
            putrc( "SPXEstablishConnection", rc );
        }
    #endif
    return( 0 );
}
Example #7
0
bool RemoteConnect( void )
{
    PostListens();
    if( !Listening ) {
        _DBG_IPX(("Listening for connection\r\n"));
        _INITSPXECB( Conn, 1, 0, 0 );
        CSPXListenForConnection( 0, 0, &Connection, &ConnECB );
        Listening = 1;
    } else if( !InUse( ConnECB ) && Completed( ConnECB ) ) {
        _DBG_IPX(("Found a connection\r\n"));
        return( TRUE );
    }
    NothingToDo();
    return( FALSE );
}
Example #8
0
void RemoteDisco( void )
{
    int         i;

    _DBG_IPX(("RemoteDisco\r\n"));
    /* make sure last packet gets sent out */
    MyDelay( TICKS_PER_SEC/2 );

    Listening = 0;
    _INITSPXECB( Conn, 1, 0, 0 );
    CSPXTerminateConnection( Connection, &ConnECB );
    for( i = NUM_REC_BUFFS-1; i >= 0; --i ) {
        if( InUse( RecECB[i] ) ) {
            SPXCancelEvent( &RecECB[i] );
        }
    }
    SPXCancelEvent( &SendECB );
    for( i = NUM_REC_BUFFS-1; i >= 0; --i ) {
        RecECB[i].status = 0;
    }
}