Tuesday, September 6, 2011

SO_OOBINLINE example


Setting the SO_OOBINLINE Option

In some circumstances limited amounts of data can be expedited ahead of data that might already be sent. Normally, this out-of-band data is received using a different method from the usual data receiving functions. There are times, however, when it is preferred to receive this out-of-band data in the normal manner. When this method is chosen, the out-of-band data arrives ahead of the normal data as part of the normal data stream. To enable this feature, you could use the following code:

Example

int z;  /* Status code */
int s;  /* Socket s */

int so_broadcast;
. . .
so_broadcast = TRUE;
z = setsockopt(s,
               SOL_SOCKET,
               SO_OOBINLINE,
               &so_oobinline,
               sizeof so_oobinline);
if ( z ) {
   perror("setsockopt(2)");
}

After the option SO_OOBINLINE has been enabled, the out -of-band data will be received with the normal data. In this manner, the out-of-band data received is indistinguishable from the normal data.

See Also
SO_PASSCRED & SO_PEERCRED, SO_BROADCAST, SO_KEEPALIVE, SO_LINGER, SO_REUSEADD, SO_TYPE

No comments:

Post a Comment