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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T11:22:10+00:00 2026-05-15T11:22:10+00:00

I’m developing a encrypted chatting program that works in LAN it also should be

  • 0

I’m developing a encrypted chatting program that works in LAN it also should be able to send file.here is the problems:
1-For chatting part it only send 1 message and close the connection, the other party should run the program again in order to receive further messages, I tried to put it in a loop like this
( receive close and receive again), but the program crashed,

I have the same problem for receiving files,
Any idea how can I solve this problem?
This is the code
IP = textBox2.Text.ToString();
int port = int.Parse(textBox1.Text);
IPAddress IP2 = IPAddress.Parse(IP);
TcpListener TCPListen = new TcpListener(IP2, port);

                TCPListen.Start();

            TcpClient TCP = TCPListen.AcceptTcpClient();
            //bool a = false;

            NetworkStream NetStream = TCP.GetStream();



            //while (!a)
            //{

            RijndaelManaged RMCrypto = new RijndaelManaged();


            byte[] Key = { 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16 };
            byte[] IV = { 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16 };




            CryptoStream CryptStream = new CryptoStream(NetStream,
               RMCrypto.CreateDecryptor(Key, IV),
               CryptoStreamMode.Read);

            StreamReader SReader = new StreamReader(CryptStream);




            message = SReader.ReadToEnd();

            textBox3.Clear();

            textBox3.Text = message;

            CryptStream.Flush();

            SReader.Close();


            //encryption(NetStream);




            NetStream.Flush();

            NetStream.Close();

            TCPListen.Stop();
            TCP.Close();

And it is in a loop like
bool a = false;
while(!a) it means continuously do it.

  • 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-15T11:22:11+00:00Added an answer on May 15, 2026 at 11:22 am

    First, you’re making this far more complicated than it has to be. There isn’t really any need to deal directly with sockets or even the TcpClient for things like this anymore. Use WCF to have clients communicate with each other. It would be extremely simple to do, and you don’t have to worry about all of this tediousness. WCF handles all of the piping for you.

    Secondly, if you were going to do it the way you are doing – you can open a NetworkStream or SslStream and “read” and “write” to that stream to handle all your communication. The easiest way is going to be by doing everything over one connection/stream. That would mean you can’t chat, while your transferring files though. As soon as you bring another stream into the picture, that is another order of magnitude more complicated, because now you have to manage the connection and lifetime of that stream, in addition to your main stream. It seems to me, this approach could be very brittle – because most of your code would have to be around recovering from problems. What if someone reboots a router while you are communicating? What happens if the sending of your file fails? Because you are handling this at such a low level, this would require a lot of code – just to fail gracefully.

    Again, I would positively use WCF for this. Hope that helps.

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

Sidebar

Ask A Question

Stats

  • Questions 473k
  • Answers 473k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer I was using the wrong version 1.5.2 which has that… May 16, 2026 at 4:06 am
  • Editorial Team
    Editorial Team added an answer This works however the primary key of the current column… May 16, 2026 at 4:06 am
  • Editorial Team
    Editorial Team added an answer def round_up(number) divisor = 10**Math.log10(number).floor i = number / divisor… May 16, 2026 at 4:06 am

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.