I'm developing an Android real-time-data app that sends data (floats and ints) to a server on the local subnet via a TCP socket. The problem I'm facing is that after sending some data simultaneously the socket doesn't send anymore data at all. I debugged the app and it shows that data is being sent but doesn't show up on the server. After this happens if I close the connection the server doesn't even get the notification that the connection has been terminated which it should according to my design model. Meanwhile I get an exception on the app saying it can not write to a broken pipe. This tells me that the problem is with the app because I also did test using a desktop app and I can send huge amounts of data to the server and it gets delivered.

And please keep in mind that the data size I'm talking about here is **252 bytes** per packet.

Here's my class I'm using. (This runs in an `AsyncTask` object )

```
    public class Network
{
    private Socket handle;
    public static enum TASK
    {
        TASK_CONNECT, TASK_SEND, TASK_CLOSE 
    }
    public Network()
    {

    }
    public String lastError = "";
    public boolean Connect(String host, int port)
    {
        try
        {
            lastError = "Connecting to server.";
            handle = new Socket(host, port);

            handle.setTcpNoDelay(true); //                         
            handle.setSendBufferSize(SIZE_OF_PACKET);  ///==> These don't seem to help at all
            handle.setKeepAlive(true); ///                          

            return true;
        }catch(IOException e)
        {
            lastError += e.getMessage() != null ? " "+ e.getMessage() : "";
            return false;
        }
    }
    private void err(String e){
        System.err.println(e);
    }

    private boolean SendPacket(byte buffer[])
    {
        OutputStream oStream = null;
        err("sending: " + buffer.length + " bytes");

        try
        {
            lastError = "Obtaining output stream.";
            oStream = handle.getOutputStream();

            lastError = "Error sending data.";
            oStream.write(buffer);

            oStream.flush();

            return true;
        }catch(Exception e)
        {
            lastError += e.getMessage() != null ? " "+ e.getMessage() : "";
        }
        return false;
    }

    public void Close()
    {
        try{ handle.close(); handle = null; }catch(Exception e){} // swallow exception
    }
}

```

I send my data in a loop depending on how many numbers I have. I tried a Google search but didn't find anything relevant. Has anyone experienced this before? It's making me mad now.

**EDIT**: Wireshark shows incoming "red" packets that don't reach the desktop app (server)
Look at this picture. 
![enter image description here](https://i.stack.imgur.com/GOMzC.png)
You can see the first few have **Len > 0** the red ones have 0.

I think it's time Google interfaced the USB so we can use it. At least that'd would have been my first option.