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

  • Home
  • SEARCH
  • 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 1838386
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T06:28:15+00:00 2026-05-17T06:28:15+00:00

I am writing two console applications, a client and a server. I’m a little

  • 0

I am writing two console applications, a client and a server.
I’m a little stuck at two things, which seemed rather easy at first..

#1: I want to write a function for the following piece of code, that converts bits to a string, but I cant just figure it out. The server always crashes when I use it. My function is a little bit different than this one, but that’s because my current code has to include the connection information, and I think there’s a better way to do it:

        byte[] b = new byte[100];
        int k = s.Receive(b);

            string packet = null;
        for (int i = 0; i < k; i++)
        {
            Console.Write(Convert.ToChar(b[i]));
            packet = packet + Convert.ToChar(b[i]);
        }

I guess the function is not the problem, but how I use it is. Any help would be very much apreciated.

Edit:
I am calling and using it like this:

    byte[] b = new byte[100];
    string response = BitConvert(b);

    if (response == "Hi there")

#2 I want the client to álways send a packet just once, with a password. And if that password doesn’t match the password mentioned as a string in the server, it should close the connection with the client.

I know how to send the packet just once, but I don’t know how to check the packet in the server just once for each client.

Or in other words, at the moment the server has no way of knowing if the client has already been authenticated. So I guess the client needs to have some sort of socket ID, and the server needs a table with the ID, and a boolean to see if it’s autenticated or not.

  • 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-17T06:28:15+00:00Added an answer on May 17, 2026 at 6:28 am

    The first part, getting the bytes into a string … how about:

    byte b[] = new byte[100];
    int k = s.Receive(b, b.Length, 0);
    
    string packet = Encoding.ASCII.getString(b, 0, k);
    

    Part 2 … not sure off the top of my head.

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

Sidebar

Related Questions

I'm writing a WinForms app which has two modes: console or GUI. Three projects
I am writing a program which has two panes (via CSplitter ), however I
I am writing an application which blocks on input from two istreams . Reading
I have the option of writing two different formats for a database structure: Article
Consider the following two ways of writing a loop in Java to see if
When writing a switch statement, there appears to be two limitations on what you
I'm writing a program that contains a generational garbage collector. There are just two
In my console application have an abstract Factory class Listener which contains code for
I have two C# applications, one is reading a file (File A) line by
I am writing a simple console application in Objective-C but I have heard that

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.