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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T12:21:06+00:00 2026-06-13T12:21:06+00:00

I created a client in Java and I want simply to send some data

  • 0

I created a client in Java and I want simply to send some data to my server that is in C#.

The problem is that if I write in the client for example hello, I get only the first letter. In the byte array there is only one element.

I guess there is some problem with the server side because in my server in JAVA works everything fine so the client in JAVA works fine.

Does anybody see any problem?

Thank you in advance.

  • 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-13T12:21:07+00:00Added an answer on June 13, 2026 at 12:21 pm

    problem is prabably in java side because your listener works fine.
    I copy pasted your listener code in a test application.
    Than I created another test applicationand send hello word and I listened it completely.

    public static  void sender()
    {
      TcpClient client = new TcpClient();
      IPEndPoint serverEndPoint = new IPEndPoint(IPAddress.Parse("192.168.2.236"), 30000);
      client.Connect(serverEndPoint);
      NetworkStream clientStream = client.GetStream();
      ASCIIEncoding encoder = new ASCIIEncoding();
      byte[] buffer = encoder.GetBytes("Hello Server!");
    
      clientStream.Write(buffer, 0, buffer.Length);
      clientStream.Flush();
    }
    
    
    Connection accepted from 192.168.2.236:22811
    Recieved...
    Hello Server!
    

    Btw, this might be better listener.

    public void listener()
        {
      TcpListener tcpListener = new TcpListener(IPAddress.Any, 30000);
      tcpListener.Start();
    
      TcpClient tcpClient = tcpListener.AcceptTcpClient();
      NetworkStream clientStream = tcpClient.GetStream();
    
      byte[] message = new byte[4096];
      int bytesRead;
    
      while (true)
      {
        bytesRead = 0;
    
        try
        {
          //blocks until a client sends a message
          bytesRead = clientStream.Read(message, 0, 4096);
        }
        catch
        {
          //a socket error has occured
          break;
        }
    
        if (bytesRead == 0)
        {
          //the client has disconnected from the server
          break;
        }
    
        //message has successfully been received
        ASCIIEncoding encoder = new ASCIIEncoding();
        Console.Write(encoder.GetString(message, 0, bytesRead));
      }
    
      tcpClient.Close();
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have created a server in java which accepts client connections. But I am
I've recently created a fairly simple IRC client and server in Java but to
Assume that i have created a client TCP Socket in Activity A. I want
I would like to create a simple XMPP client in java that shares his
In java it is possible to create a socket server and a socket client,
A client im working for has created a web app that uses a password
I am Java and Maven newbie and I want to create a simple client
I want to put some compressed data into a remote repository. To put data
Im having some trouble determining how to write files using a Java Web Start
I want to create a simple server client application, but i think there is

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.