1

I need to send a big amount of data with a single shot. But socket_write sends only a part of it. The function and the $buffer variable are correct:

socket_write($socket, $buffer, strlen($buffer));

Maybe it is possible to customize the limit of buffer or something?

There are many solutions on this issue at http://php.net/manual/en/function.socket-write.php but they all separating buffer to send it part by part.

1 Answer 1

2

You should try setting the send buffer size using the SO_SNDBUF option. This would allow the buffer at TCP layer to hold more data.

$sock = socket_create(AF_INET, SOCK_STREAM, SOL_TCP) socket_set_option($sock, SOL_SOCKET, SO_SNDBUF, 5000);

You can see the current value of the socket buffer using the socket_get_option: var_dump(socket_get_option($sock, SOL_SOCKET, SO_SNDBUF));

URL: https://www.php.net/manual/en/function.socket-set-option.php

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.