I am trying to send a long string via telnet to my application.
in my application, I set up a socket with:
{ok, Sock} = gen_tcp:listen(Port, [{active, true}, {reuseaddr, true}],
{ok, Sock} = gen_tcp:accpet(Sock),
% start a process when someone connects
{ok, Pid} = my_sup:start_handler(Sock),
inet:setopts(Socket,[{active, once},{buffer, 2310731}, {recbuf, 1310731},{sndbuf, 1310731}]),
gen_tcp:controlling_process(Socket, Pid),
My process that handles the connected client is a gen_server and I use the standard
handle_info ({tcp, Sock, Data}, State) ->
to receive and process the incomming message from the sender.
Initially, I could only send a string of about 1,500 characters, then I added the setopts/2 command to increace buffer sizes. But I cannot get the socket to handle more than about 3,160 charcters.
I have printed out the values via getopts and verified that they are what is represented in the setopts/2 call.
I can utilize my http interface to POST string values at least 4 times as large and can get them via the telnet / socket client…
What am I missing?
If you don’t specify
packetorlineoption you will receive only what was send by one TCP packet. So if you want receive more you have to write our own receive loop and protocol. Additional data are just waiting in buffers but you hadn’t collected them.