質問

だからこれは最初の最初の先頭に2つの部分の質問です。

私はPHP Serverプロジェクトに取り組んでいます。私はそれぞれ新しい方法を使ってそれぞれ3つのソケットを作成することができました。誰かがこれら3つの方法の間の基本的な違いを知っていますか?

方法1 'socket_create' を使った

$Socket1 = socket_create(AF_INET, SOCK_STREAM, SOL_TCP)
socket_bind($Socket1, $LocalIP, $LocalPort)
socket_connect($Socket1, $DestIP, $DestPort)
//Method 1 Read
socket_read($Socket1)
//Method 1 Write
socket_write($Socket1, $WriteMsg, strlen($WriteMsg))
.

方法2「FSOCKOPEN」を使用する

$Socket2 = fsockopen($Server, $Port)
//Method 2 Read
fgets($Socket2)
//Method 2 Write
fputs($Socket2, $PutMsg, strlen($PutMsg))
.

方法3 'stream_socket_client' を使用する

$Socket3 = stream_socket_client('tcp://'.$DestIP.':'.$DestPort)
//Method 3 Read
stream_socket_recvfrom($Socket3, $RecSize)
//Method 3 Write
stream_socket_sendto($Socket3, $SendMsg)
.

私は違いを理解していませんが、TCPウィンドウサイズを制御する方法を探している3つのオプションすべてを探索していました。私は1460バイトのデータペイロードを持ち、パケットキャプチャを検討した後、私のパケットのTCPデータ部分は常に1448バイトで常にカットされた後にパケットをクライアントにプッシュしようとしています。任意のアイデア?

事前にありがとう!

役に立ちましたか?

解決

You can't control the actual amount of data received at a time. TCP is a streaming protocol. It presents a byte-stream API to the application. You just have to be prepared to read and re-read until you have got what you want.

他のヒント

You should be able to do this with the socket_set_option command (where options are documented in the socket_get_option command):

$Socket1 = socket_create(AF_INET, SOCK_STREAM, SOL_TCP)
// send window
socket_set_option($Socket1, SOL_SOCKET, SO_SNDBUF, 1460);

Just be sure to call it right after socket_create. If you need the receive window modified:

socket_set_option($Socket1, SOL_SOCKET, SO_RCVBUF, 1460);
ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top