[erlang-questions] gen_tcp send non-blocking in erlang?

Vinoth Kumar vinothsparrow@REDACTED
Mon Mar 17 10:32:13 CET 2014


I have used both first and second step requested (i.e. {send_timeout,0} and erlang:port_command(Socket,Data)) but these methods also returns the same. Returns OK while tcp packets has not been delivered(i.e. TCP ack not received). The packet is pushed into the queue and trying to send. So i want an async send mechanism to check whether the  packet has been sent to receiver. If packet delivered means just returns ok otherwise will return {error,timeout}
Thanks,Vinoth Kumar J
Date: Mon, 17 Mar 2014 12:53:41 +0400
Subject: Re: [erlang-questions] gen_tcp send non-blocking in erlang?
From: max.lapshin@REDACTED
To: vinothsparrow@REDACTED
CC: erlang-questions@REDACTED

It is a very, very dangerous practice, because you loose control over your program with non-blocking send.
First step that you MUST do is setting send_timeout on socket. By default it is infinity and it means that your process may get blocked forever trying to push data.

I don't know why infinity is a default value, it is really strange for me.
Second, dangerous step is just using port_command(Socket, IoData). Then you must wait for messages from this socket. But don't use it =)

 		 	   		  
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20140317/01b73065/attachment.htm>


More information about the erlang-questions mailing list