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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T01:26:18+00:00 2026-05-24T01:26:18+00:00

The basic rundown is… 1) My application starts a Java process and manages it.

  • 0

The basic rundown is…

1) My application starts a Java process and manages it.

2) I have a TCP Server in another thread that users can connect to and issue commands that the Java process understands.

3) Passing the commands is not a problem is streamWriter.WriteLine(cmd); but getting the response is proving to be difficult.

The next line that comes in through RedirectStandardError (it uses this instead of Output for some reason) should be the reply, but I am having trouble figuring out how to access that in my TCP Server’s thread.

This is what my TCP Server’s function looks like that needs to get the reply and print it out. How can I go about doing this?

    static void AcceptClient(IAsyncResult ar)
    {
        TcpListener rconListener = ar.AsyncState as TcpListener;
        TcpClient rconClient = rconListener.EndAcceptTcpClient(ar);
        Console.WriteLine("New client: " + rconClient.Client.RemoteEndPoint.ToString());

        NetworkStream ns = rconClient.GetStream();

        // Loop while client is Connected
        while (rconClient.Connected)
        {
            byte[] buff = new byte[4096];
            List<byte> msg = new List<byte>();
            int total = 0;

            while (true)
            {
                int read = ns.Read(buff, 0, buff.Length);
                if (read <= 0)
                    break;

                msg.AddRange(buff);
                total += read;

                if (read < buff.Length)
                    break;
            }
            if (msg.Count <= 0)
            {
                Console.WriteLine("Lost connection: " + rconClient.Client.RemoteEndPoint.ToString());
                rconClient.Close();
                break;
            }

            int len = BitConverter.ToInt32(msg.ToArray(), 0);
            int seq = BitConverter.ToInt32(msg.ToArray(), 4);

            PacketType packetType = (PacketType)BitConverter.ToInt32(msg.ToArray(), 8);
            List<byte> response = new List<byte>();


            // RCON Execute Command
            if (packetType == PacketType.ServerData_ExecCommand_AuthResponse)
            {
                string srvcmd = ReadString(msg.ToArray(), 12);
                Console.WriteLine("RCON: " + srvcmd);

                response.AddRange(BitConverter.GetBytes((int)seq));
                response.AddRange(BitConverter.GetBytes((int)PacketType.ServerData_ResponseValue));

                string[] cmdargs = srvcmd.Split(new char[] { ' ' });

                if (cmdargs[0] == "rcon_password")
                {
                    ServerSettings.RCONPassword = cmdargs[1];
                    response.AddRange(Encoding.ASCII.GetBytes("RCON Password succesfully changed to " + cmdargs[1]));
                }
                else if (cmdargs[0] == "date")
                {
                    response.AddRange(Encoding.ASCII.GetBytes(DateTime.Now.ToString()));
                }
                else
                {
                    Program.SendRCONCmd(cmdargs[0]);
                }


                response.AddRange(new byte[] { 0x20, 0x0a }); //LF
                response.Add(0x0);
                response.Add(0x0);
                response.InsertRange(0, BitConverter.GetBytes((response.Count)));
                ns.Write(response.ToArray(), 0, response.Count);
            }
        }
    }
  • 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-24T01:26:20+00:00Added an answer on May 24, 2026 at 1:26 am

    have you checked the SDK documentation?

    Process.StandardError Property

    Gets a stream used to read the error output of the application.

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

Sidebar

Related Questions

really basic question, I have a string to generate as SQL statement that I
Basic SQL statement question - I have a table (myUsers) that contains the column
basic overview... i have a site setup in iis... - mysite (wwwroot\mysite) under that
I am trying to develop a very basic console application that will retrieve a
Basic C++ class question: I have simple code currently that looks like something like
Basic premise: I have a Room which publishes an event when an Avatar enters
Basic C# syntax question: So I have this class public class BrandQuery<T> : Query<T>
Basic question: Including a page, that contains a component with component id, multiple times
Pretty Basic one here guys. I have a View which holds 2 textfields for
Basic question; I have this code: var partipiansRow = '<div class=form-row ><input type=text id=name

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.