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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T03:59:15+00:00 2026-06-15T03:59:15+00:00

I want to send a few gyroscope readings from my android device to a

  • 0

I want to send a few gyroscope readings from my android device to a PC program (C#) . I decided to do it via socket programming. Android phone acts as client and the Program running on the computer acting as the server.
Here is my android code which sends “hello” for now :

try
{
    socket = new Socket("192.168.1.3", 1071);
PrintWriter pw=new PrintWriter(new BufferedWriter(new OutputStreamWriter(socket.getOutputStream())));
pw.println("Hello");
    socket.close();
}
catch (UnknownHostException e) {
     // TODO Auto-generated catch block
     e.printStackTrace();
    }
catch (IOException e) {
     // TODO Auto-generated catch block
     e.printStackTrace();
    }

and now the c# server code looks like this:

        listener = new TcpListener(1071);
        listener.Start();
        Socket soc;
        while (true)
        {
             soc= listener.AcceptSocket();
            Console.WriteLine("Connection accepted from " + soc.RemoteEndPoint);

            byte[] b = new byte[10000];
            int k = soc.Receive(b);
            Console.WriteLine(k);
            char cc = ' ';
            string test = null;
            Console.WriteLine("Recieved...");

            for (int i = 0; i < k - 1; i++)
            {
                Console.Write(Convert.ToChar(b[i]));
                cc = Convert.ToChar(b[i]);
                test += cc.ToString();
            }
        }
        soc.Close();
    }

The problem is that the connection is established, but I am not able to recieve anything at the server. The value of k is zero everytime. But the connection is successfull.

Output:
Connection accepted from 192.168.1.6:36742
0
Recieved...
Connection accepted from 192.168.1.6:57013
0
Recieved...

and so on.

Can anybody tell me what might be the issue, I am pretty sure that the encoding issues such as UTF-8 are not present.

  • 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-15T03:59:16+00:00Added an answer on June 15, 2026 at 3:59 am

    It looks like you missed flushing your PrintWriter before you close it.

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

Sidebar

Related Questions

I want to send few dictionaries from django to android through HTTP after getting
I want to send a few variables and a string with the POST method
Want to send the text from my current vb application to the Active Window
I have a few arrays that I want to send to process with PHP.
I want to send a JavaScript AJAX call to a C# server every few
I want to send a message to the server comprises of a few different
Basically I want to be able to send a few second delayed live feed
I want to send a message (a serializable object) from a java instance to
I've seen a few questions left half-answered regarding this topic. I want to send
I want to send a few commands (functions) that are inside a simple .sh

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.