Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7939395
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T23:05:11+00:00 2026-06-03T23:05:11+00:00

I have a Client/ server application where the Server is in java and Client

  • 0

I have a Client/ server application where the Server is in java and Client is in Vb.net.

When i send large string from client to server am not receiving complete text.
please help.

code attached below.

client– VB.net-

      Try
         Dim clientSocket As New System.Net.Sockets.TcpClient()

        ' msg("Client Started")
        clientSocket.Connect(StrIP_Add, intPort)
        clientSocket.SendBufferSize=104857600
        '6511 6522
        ' Label1.Text = "Client Socket Program - Server Connected ..."

        Dim serverStream As NetworkStream = clientSocket.GetStream()
        Dim outStream(104857600) As Byte

        ' MsgBox(strValidator.Trim.Length)

        outStream = System.Text.Encoding.ASCII.GetBytes(strValidator.Trim)
        ' Dim outStream As Byte() = "sdsfd"
        System.Threading.Thread.Sleep(2000)
        serverStream.Write(outStream, 0, outStream.Length)
        System.Threading.Thread.Sleep(2000)
        serverStream.Flush()

        Dim inStream(104857600) As Byte
        serverStream.Read(inStream, 0, outStream.Length) '104857600) ' CInt(clientSocket.ReceiveBufferSize))
        Dim returndata As String = _
        System.Text.Encoding.ASCII.GetString(inStream)
        '  msg("Data from Server : " + returndata)
        clientSocket.Close()

    Catch ex As Exception
        ' VikUcMsg.AddMessage("<b><u>" & Page.Title & "</u></b><br><br>" & "No Connectivity on the port :" & intPort, enmMessageType.Error)


    End Try

server– Java

BufferedInputStream RecievedBuffer = new BufferedInputStream(
                TCPIP_Client_SOCKET.getInputStream());
        InputStreamReader RecievedInputStreamReader = new InputStreamReader(
                RecievedBuffer);

        System.out.println(RecievedBuffer.toString().length());
        //char[] RecievedChars = new char[TCPIP_Client_SOCKET
                //.getReceiveBufferSize()];

        char[] RecievedChars = new char[100000];
        //Thread.sleep(5000);
        RecievedInputStreamReader.read(RecievedChars);
        //Thread.sleep(5000);
        String strRecievedData=null;
        //Thread.sleep(5000);
        strRecievedData = new String( RecievedChars ).trim();
        //strRecievedData = RecievedChars.;
        Thread.sleep(5000);
        if (strRecievedData!=null)
        {
            System.out.println(strRecievedData);
                         }

strRecievedData is only havig 8192 all the time.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-03T23:05:13+00:00Added an answer on June 3, 2026 at 11:05 pm

    Well the short answer is that you must loop when reading from a socket because there is no guarantee how many bytes you will receive on each attempt to read.

    Psuedo-code:

    while (!msgCompleted && !overallTimeout)
    {
       bytesRead = netstream.Read(readBuffer);
    
       if (bytesRead > 0)
       {
          // here append readBuffer to msgBuffer from offset to offset+bytesRead 
    
          offset += bytesRead // update offset so you can keep appending
    
         // inspect the msgBuffer to see if the message is completed
       }
    
    }
    

    That all being said, you’ve got nyumerous other problems in your code. For example…

    You allocate a 104857601 (not 104857600) byte buffer here:

    Dim outStream(104857600) As Byte

    And then discard and replace that buffer with whatever contents get reurned from strValidator:

    outStream = System.Text.Encoding.ASCII.GetBytes(strValidator.Trim)

    No point in pre-allocating it just to replace it.

    Another one…

    You allocate an input buffer of a certain length:

    Dim inStream(104857600) As Byte

    But then read into that buffer using the length of a different buffer:

    serverStream.Read(inStream, 0, outStream.Length)

    This is prone to errors depending on the lengths.

    You will also need to loop in this VB read just as for the Java read.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have written a java client server application (not http), which i need to
I have developed a java swing client-server application. The server has many services like
Background: I have written a java swing based client server application. The server is
I have a project to develop a client server application in java . This
I have a client Server application which communicate using objects. when I send only
I have a client-server java application, where communication happens over SSL. Right now I
I would like to create a server using .NET and Java client (Android application).
I have server and client code that works perfectly as a Java application. The
I have client/server application where the client app will open files. Those files get
I have a Client/Server application, where the Client and Server have some common tables

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.