# Send disconnect socket from flash

**URL:** <https://forum.kirupa.com/t/send-disconnect-socket-from-flash/291132>\
**Category:** programming\
**Created:** [June 25, 2009, 12:24am UTC](https://forum.kirupa.com/t/send-disconnect-socket-from-flash/291132 "2009-06-25T00:24:06Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![arborvan37](https://avatars.discourse-cdn.com/v4/letter/a/85e7bf/32.png) [@arborvan37](https://forum.kirupa.com/u/arborvan37)\
**Post date:** [June 25, 2009, 12:24am UTC](https://forum.kirupa.com/t/send-disconnect-socket-from-flash/291132/1 "2009-06-25T00:24:06Z")

</div>

ok so :

```auto

 
               // socket_recv just receives data from $socket as $buffer, with an integer length of 2048, and a mystery flag set to 0 
            // that mystery flag has no real documentation so setting it to 0 will solve it as others have done. 
            // we've also set it as a var $bytes in case we need to ensure data sending with socket_write, which is optional 
           $bytes = socket_recv($socket, $buffer, 2048, 0); 
            
           // if the $bytes we have is 0, then it is a disconnect message from the socket 
           // we will just search for it as an index and unset that socket from our $read_sockets and 
           // finish up with using socket_close to ensure it is closed off 
           if ($bytes == 0) { 
               $index = array_search($socket, $read_sockets); 
               unset($read_sockets[$index]); 
               socket_close($socket);

```

I need socket\_recv($socket, $buffer, 2048, 0); to return zero.

and I looked up the function at [http://www.navioo.com/php/docs/function.socket-recv.php](http://www.navioo.com/php/docs/function.socket-recv.php)

it says :

## Return value:

a) on success returns number of bytes read  
b) in case of no data on line, returns zero and $buf will be set to NULL.  
c) on failure returns false, and $buf will be set to NULL.  
To get the error code/message, call the appropriate socket functions.  
d) in case of disconnect, the function returns either b) or c) which depends on how connection was closed from the other end. It returns 0 if the connection was closed gracefully with FIN squence and false if it was reset.

ok so how do I send “no data on line” from flash?  
i tried (actionscript2.0):  
mySocket.send("\x00");  
mySocket.send("");  
mySocket.send(null);  
im not sure what else to do
