Aprial 28th Statusday (四月 二十八日 土曜日)

Many transport layers have the concept of out-of-band data, which is sometimes called expedited data.  The
idea is that something important occurs at one end of a connection and that end wants to tell its peer quickly.
By "quickly" we mean that this notification should be sent before any "normal" (sometimes called "in-band") data that is already queued to be sent, and should be sent regardless of any flow control or blocking issues. That is, out-of-band data is considered higher priority than normal data. Instead of using two connections between the client and server, out-of-band data is mapped onto the existing connection.

TCP does not have true out-of-band data. Instead, TCP provides an urgent mode. Assume a process has written N bytes
of data to a TCP socket and that data is queued by TCP in the socket send buffer, waiting to be sent to the peer.

The process now writes a single byte of out-of-band data, containing the ASCII character a, using the send function
and the MSG_OOB flag.

send(fd, "a", 1, MSG_OOB);

TCP places the data in the next available position in the socket send buffer and sets its urgent pointer for this
connection to be the next available location.

We now show a simple example to illustrate the following two features of the out-of-band mark:

The out-of-band mark always points one beyond the final byte of normal data. This means that, if the out-of-band data
is received inline, sockatmark returns true if the next byte to be read is the byte that was sent with the MSG_OOB flag.
Alternately, if the SO_OOBINLINE socket option is not enabled, then sockatmark returns true if the next byte of data
is the first byte that was sent following the out-of-band data.

A read operation always stops at the out-of-band mark. That is, if there are 100 bytes in the socket receive buffer,
but only 5 bytes until the out-of-band mark, and the process performs a read asking for 100 bytes, only the 5 bytes
up to the mark are returned. This forced stop at the mark is to allow the process to call sockatmark to determine if
the buffer pointer is at the mark. 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值