--- a/src/applications/packet-sink/packet-sink.cc Wed Dec 10 21:11:05 2008 -0800 +++ a/src/applications/packet-sink/packet-sink.cc Thu Dec 11 14:23:34 2008 -0500 @@ -119,6 +119,10 @@ Address from; while (packet = socket->RecvFrom (from)) { + if (packet->GetSize() == 0) + { //EOF + break; + } if (InetSocketAddress::IsMatchingType (from)) { InetSocketAddress address = InetSocketAddress::ConvertFrom (from); --- a/src/internet-stack/tcp-socket-impl.cc Wed Dec 10 21:11:05 2008 -0800 +++ a/src/internet-stack/tcp-socket-impl.cc Thu Dec 11 14:23:34 2008 -0500 @@ -473,6 +473,11 @@ NS_LOG_FUNCTION_NOARGS (); if(m_bufferedData.empty()) { + if(m_state == CLOSE_WAIT) //means EOF + { + return Create(); + } + //else, means nothing to read return 0; } UnAckData_t out; //serves as buffer to return up to the user @@ -547,7 +552,8 @@ { NS_LOG_FUNCTION (this << maxSize << flags); Ptr packet = Recv (maxSize, flags); - if (packet != 0) + //Null packet means no data to read, and an empty packet indicates EOF + if (packet != 0 && packet->GetSize() != 0) { SocketAddressTag tag; bool found;