Erlang sockets: sending back FIN/RST early?
===

**tl;dr** : Wireshark says that gen_tcp is sending `FIN`,`RST` flags before I can finish receiving *all* of my data...

I'm receiving data from an active socket via gen_tcp. It's coming from an (un-encrypted) OpenSSL socket via BIO_write() (see http://linux.die.net/man/3/bio_write) and gen_tcp is listening with the following options:

`[binary,{packet,0},{active,true},{reuseaddr,false},{recbuf,256000}]`

I'm running this using the Win32 distro of Erlang/OTP and expect to receive some pretty large data, thus the large recbuf. This has worked okay for me in the past.

I'm getting only the first 1516 bytes from each packet, then gen_tcp sends back a `FIN`, and I can't figure out why that is.

Here's a snap of my wireshark:

![enter image description here][1]

The blue line is the "header" packet, sending over the protocol version. The chunk that follows with the data length of "Len=1460" is the first big data blob. Then the ACK @ #3, and Erlang barfs with a `FIN` @ #4

The yellow line is the last chunk of data successfully sent over.

Any ideas?


  [1]: http://i.stack.imgur.com/ZitSF.png