[Previous] [Contents] [Index] [Next]


Open a communications channel


struct _Ph_ctrl *PhAttach( 
                     char const *name,
                     PhChannelParms_t const *parms );


This function opens a communications channel to a Photon Manager. The channel becomes the current channel.

Note: The application must call the PhAttach() function before it calls any other Photon functions. Both PtInit() and PtAppInit() invoke this function.

A Photon channel contains:

The name argument contains the name registered by a Photon Manager. If you pass NULL, the function uses the PHOTON environment variable. If PHOTON isn't set, the function uses /dev/photon instead.

The parms argument lets you fine-tune the resources of the channel. Passing NULL to this argument gets the channel defaults:

If you don't pass NULL to parms, you should pass a pointer to a PhChannelParms_t structure, which contains at least:

mpid_t   proxy;
unsigned long  max_q_entries;
unsigned long  flags; 


Your own proxy instead of the one that the channel would otherwise obtain. This member is valid only if you set the Ph_NO_PROXY bit in flags.
The maximum number of queues likely to be needed. The Photon Manager may override this value.
Defined flags:
Don't allow the channel to obtain a proxy unless the proxy member of PhChannelParms_t contains a proxy. This flag prevents the PhEventArm()/PhEventRead() combination from working. You should find this flag useful when proxies are a limited resource.
Don't block the client if it overflows another application's event queue.
If there's a pending Photon event that's larger than the client's event buffer, send an event that indicates how large the client's buffer needs to be to receive the entire event message. For more information, see PhEventNext(), PhEventRead(), and PhGetMsgSize().

Note: If you attach communications channels to multiple Photon managers, you'll have to keep track of which regions belong to which manager.


A pointer to a control structure.


promiscuous_call( void )
     struct _Ph_ctrl *ph1, *ph2, *ph3;
     ph1 = PhAttach( NULL, NULL );
     if( ph1 )
          printf( "ph1 is the current channel to: "
             "the local Photon kernel\n" );
     ph2 = PhAttach( "/dev/photon", NULL );
     if( ph2 )
          printf( "ph2 is the current channel to: "
             "the local Photon kernel\n" );
     ph3 = PhAttach( "//83/dev/photon", NULL );
     if( ph3 )
          printf( "ph3 is the current channel to: "
             "the Photon kernel on node 83\n" );
     if( !ph1 | !ph2 | !ph3 )
     return( -1 );

     PhReattach( ph1 );
     printf( "ph1 is the current channel again\n" );
     PhDetach( ph1 );
     printf( "there is no current channel\n" );
     PhReattach( ph3 );
     printf( "ph3 is the current channel again\n" );
     PhDetach( ph2 );
     PhDetach( ph3 );
     printf( "all Photon channels closed\n" );
     return( 0 );



Interrupt handler No
Signal handler No
Thread No

See also:

PgSetDrawBufferSize(), PhDetach(), PhEventNext(), PhEventArm(), PhEventRead(), PhGetMsgSize(), PhReattach(), PtInit(), PtAppInit()

[Previous] [Contents] [Index] [Next]