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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T16:46:26+00:00 2026-06-08T16:46:26+00:00

I am making a dual app with android and kinect. I want to be

  • 0

I am making a dual app with android and kinect. I want to be able to send notifications to the android app from the kinect. I was told that the best way to accomplish this is to set up a simple tcp server. I tried to set it up by using the tutorial at this <link>. The tutorial however isn’t descriptive enough for me and I am unable to make it work. The guy who posted it basically posted several pieces of code without any instruction about assembling them. I need someone to either walk me through setting up this server or I need a link to a detailed tutorial. I have searched the web myself for hours but I haven’t found anything useful, which is why I’m asking here.

  • 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-08T16:46:28+00:00Added an answer on June 8, 2026 at 4:46 pm

    Here’s what I thought he was saying to do in that tutorial:

    using System;
    using System.Text;
    using System.Net.Sockets;
    using System.Threading;
    using System.Net;
    
    namespace TCPServerTutorial
    {
      class Server
      {
        private TcpListener tcpListener;
        private Thread listenThread;
    
        public Server()
        {
          this.tcpListener = new TcpListener(IPAddress.Any, 3000);
          this.listenThread = new Thread(new ThreadStart(ListenForClients));
          this.listenThread.Start();
        }
    
    
        private void HandleClientComm(object client)
        {
          TcpClient tcpClient = (TcpClient)client;
          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();
            System.Diagnostics.Debug.WriteLine(encoder.GetString(message, 0, bytesRead));
          }
    
          tcpClient.Close();
        }
    
        private void ListenForClients()
        {
          this.tcpListener.Start();
    
          while (true)
          {
            //blocks until a client has connected to the server
            TcpClient client = this.tcpListener.AcceptTcpClient();
    
            //create a thread to handle communication
            //with connected client
            Thread clientThread = new Thread(new ParameterizedThreadStart(HandleClientComm));
            clientThread.Start(client);
          }
        }
    
        //you'll have to find a way to pass this arg
        private void SendBack(TcpClient tcpClient)
        {
        NetworkStream clientStream = tcpClient.GetStream();
        ASCIIEncoding encoder = new ASCIIEncoding();
        byte[] buffer = encoder.GetBytes("Hello Client!");
    
        clientStream.Write(buffer, 0 , buffer.Length);
        clientStream.Flush();
        }
      }
    }
    

    But that’s just me. He only ever talked about one class, so it is logical to assume all his functions are in that class.

    For the client code, he pretty much just gives you the code for a function (in C#, of course) which will send some bytes to an IP address (aka, the IP of the machine your server is running on). You could put this function in any C# class and call it in whatever way you wish. He has hard coded the IP address and the message to send, but these could easily be arguments passed to the function.

    private void SendToServer(){
        TcpClient client = new TcpClient();
    
        //IP of the server: currently loopback, change to whatever you want
        IPEndPoint serverEndPoint = new IPEndPoint(IPAddress.Parse("127.0.0.1"), 3000);
    
        client.Connect(serverEndPoint);
    
        NetworkStream clientStream = client.GetStream();
    
        ASCIIEncoding encoder = new ASCIIEncoding();
    
        //Message being sent: "Hello Server!"
        byte[] buffer = encoder.GetBytes("Hello Server!");
    
        clientStream.Write(buffer, 0 , buffer.Length);
        clientStream.Flush();
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Making an app where we want to send a photo to a server along
Making a piano/keyboard application and trying to figure out the best way to set
Making an adobe flex ui in which data that is calculated must use proprietary
Making UML sequence diagram in VS 2010RC I've observed that there is no activation
Making websites that appear correctly in IE is a big problem. Is there any
making a new jsp and got a mock-up from some analyst. Notice the sections
Making a flash page that can cycle through these three images on mouseclick. For
Making a small WCF test program which is based on a Store that has
Making the transition from Vim to gVim, I would like to disable all toolbars
making an Access database (2003) that is mainly used by other programmers and tech

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.