I am implementing a TCP socket connection from a java to a C++ programm. Currently it's one way but should become two-way someday. My messages are pretty long (~100.000 characters). Somehow my application only sends 8192 characters/bytes at once. How can that be? Is there any tool that can help debugging? Both, client and server, run on a local windows machine. I am not familar with network programming, so any help is appreciated! Thanks alot in advance! 

Here is my code so far: 

**JAVA:**  

*make a connection:* 

```
try {
            serverSocket = new ServerSocket(socketPort);
            System.out.println("waiting for client ...");
            while (true) {
                clientSocket = serverSocket.accept();
                System.out.println("client connected.");
                if (clientSocket!=null) break;
            }
        }
        catch (IOException e) {
           System.out.println(e);
        }

```

*send stuff:* 

```
OutputStream out = clientSocket.getOutputStream();
BufferedReader in = new BufferedReader( new InputStreamReader(clientSocket.getInputStream()));

//send the new data to client
PrintWriter pw = new PrintWriter(out, true);
String outString = "VERY LONG TEXT ENDING WITH SPECIAL LETTER LIKE $";
pw.println(outString);

```

**C++:**

*make a connection*

```
bool connectToHost(int PortNo, char* IPAddress)
{
    //Start up Winsock…
    WSADATA wsadata;

    int error = WSAStartup(0x0202, &wsadata);

    //Did something happen?
    if (error)
        return false;

    //Did we get the right Winsock version?
    if (wsadata.wVersion != 0x0202)
    {
        WSACleanup(); //Clean up Winsock
        return false;
    }

    //Fill out the information needed to initialize a socket…
    SOCKADDR_IN target; //Socket address information

    target.sin_family = AF_INET; // address family Internet
    target.sin_port = htons (PortNo); //Port to connect on
    target.sin_addr.s_addr = inet_addr (IPAddress); //Target IP

    mSocket = socket (AF_INET, SOCK_STREAM, IPPROTO_TCP); //Create socket
    if (mSocket == INVALID_SOCKET)
    {
        return false; //Couldn't create the socket
    }  

    //Try connecting...
    if (connect(mSocket, (SOCKADDR *)&target, sizeof(target)) == SOCKET_ERROR)
    {
        return false; //Couldn't connect
    }
    else
        return true; //Success
}

```

*receive stuff:* 

```
if (connectToHost(3141, "127.0.0.1")) 
    {
        int iResult;
        char recvbuf[DEFAULT_BUFLEN]; // DEFAULT_BUFLEN = 1000000
        // Receive until the peer closes the connection
        do {

            iResult = recv(mSocket, recvbuf, DEFAULT_BUFLEN, 0); // DEFAULT_BUFLEN = 1000000
            if ( iResult > 0 )
            {                 
                std::cout<<"recvbuf: "<< recvbuf[strlen(recvbuf)-1]<<""<< std::endl;  //not the last character that I sent, but supposed to be
                std::cout<<"recvbuf size: "<< iResult <<""<< std::endl; //fist are 8192 and then add up until sent size 
            }
            else if ( iResult == 0 )
                printf("Connection closed\n");
            else
                printf("recv failed with error: %d\n", WSAGetLastError());

        } while( iResult > 0 );
    } else 
    {
        printf("connect failed\n");
    }

```