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 5990349
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T23:13:54+00:00 2026-05-22T23:13:54+00:00

When u know why the sent string kamote to server and the string received

  • 0

When u know why the sent string “kamote” to server and the string received “kamote” from server are not the same..

CLIENT

    tcpClient = new TcpClient();
    tcpClient.Connect(ServerIP, Port);
    connectionState = (HandShake("kamote", tcpClient)) ? "Connected to " + ServerIP.ToString() : "Host unreachable.";

    private bool HandShake(String str, TcpClient tcpClient)
    {
        using (NetworkStream ns = tcpClient.GetStream())
        {
            byte[] toServer = Encoding.ASCII.GetBytes(str);
            ns.Write(toServer,0,toServer.Length);                
            ns.Flush();

            byte[] fromServer = new byte[10025];
            ns.Read(fromServer, 0, (int)tcpClient.ReceiveBufferSize);

            return Encoding.ASCII.GetString(fromServer).Equals(str);
        }
    }

SERVER

    TcpClient tcpClient = new TcpClient();
    tcpClient = tcpListener.AcceptTcpClient();

    NetworkStream ns = tcpClient.GetStream();

    byte[] fromClient = new byte[10025];
    ns.Read(fromClient, 0, (int)tcpClient.ReceiveBufferSize);

    byte[] toClient = fromClient;
    ns.Write(toClient, 0, toClient.Length);            
    ns.Flush();       

Client sent “kamote”
Server received “kamote”
Server sent “kamote”
Client received “kamote”

HandShake() always returns false. How can I fix this?

  • 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-05-22T23:13:55+00:00Added an answer on May 22, 2026 at 11:13 pm

    As in the previous question you asked, you’re not keeping track of the number of bytes you received. So what’s happening is this:

    • On the client, you send the string “kamote”.
    • On the server, it receives that string into a buffer that’s 10025 bytes long.
    • The server then sends the entire buffer back to the client — all 10025 bytes
    • The client receives all or part of those 10025 bytes and converts them to a string.

    The string that gets converted is really “kamote” with a bunch of 0’s after it.

    You must use the return value from Read to know how many bytes you received.

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

Sidebar

Related Questions

I'm writing a client/server (as many of you probably already know!). The server is
I am having problem in java to pass cookie from client to server. In
I know how to parse the query string but I am getting sent a
We were sent this formula to encrypt a string written in Java: String myInput
I'm having a problem with my server printing what is sent to it. I
Does anyone know an easy way to generate a checksum for a String on
Does anybody know how i can get multiple popups sent via notify-send to appear
I'm not sure why this is happening. I have a string array that should
A friend sent me this and I really don't know what it is, inside
i know how can we retrive the mails from INBOX folder...but now i want

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.