Project Home
Project Home
Trackers
Trackers
Documents
Documents
Wiki
Wiki
Discussion Forums
Discussions
Project Information
Project Info
Forum Topic - Caching of _msg_info.scoid. : (2 Items)
   
Caching of _msg_info.scoid.  
In our application a server manages stateful connections to several clients. The clients always initiate communication 
with a send, and the server only replies. In the server, when we receive a message from a client, we identify which 
client the message originated from by using MsgInfo(...) and obtaining the struct _msg_info.scoid. The scoid is used to 
keep track of the connection state. 

We assume the following regarding the scoid value:
 - As connections are attached to, and detached from, the channel, a new connection will not have a previously used 
scoid associated with it.
 - The scoid is never re-assigned while connections are attached. That is if Client1 performs a ConnectAttach(...) to 
the server, then every time a message is received from Client1 the scoid will always be the same, regardless of how many
 other clients perform ConnectAttach( ... ), Send( ...)  ConnectDetach( ... ).

Please let me know if the above assumptions are valid and what is the behaviour of QNX regarding assignment and re-use 
of scoids.

In addition, suppose that the client is multi-threaded, and each thread performs ConnectAttach( ...) then Send (... ). 
In the server, when the message from each thread is received, will a different scoid be associated with each thread?
Re: Caching of _msg_info.scoid.  
> 
> We assume the following regarding the scoid value:
>  - As connections are attached to, and detached from, the channel, a new 
> connection will not have a previously used scoid associated with it.

The SCOID values should be re-used as soon as the client associated with it no longer has any CONNECTIONS.
Depending on flags set during the ChannelCreate(), specifically if _NTO_CHF_DISCONNECT is set, then SCOID are required 
to be freed by calling ConnectDetach(scoid) once you are done freeing up any lists associated with the scoid, in your 
case the state information you are keeping about each client.  Once the scoid has been freed, the scoid will be 
available for re-use.

 


>  - The scoid is never re-assigned while connections are attached. That is if 
> Client1 performs a ConnectAttach(...) to the server, then every time a message
>  is received from Client1 the scoid will always be the same, regardless of how
>  many other clients perform ConnectAttach( ... ), Send( ...)  ConnectDetach( .
> .. ).

This is true.


> 
> Please let me know if the above assumptions are valid and what is the 
> behaviour of QNX regarding assignment and re-use of scoids.
> 
> In addition, suppose that the client is multi-threaded, and each thread 
> performs ConnectAttach( ...) then Send (... ). In the server, when the message
>  from each thread is received, will a different scoid be associated with each 
> thread?

The scoid uniquely identifies a client attached to a server.  As long as the client has a valid connection, (and thus a 
scoid), other threads within the client process calling ConnectAttach() will not generate a new scoid.