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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T14:37:32+00:00 2026-05-15T14:37:32+00:00

I wrote the below code to get a string (encrypted) from the user, and

  • 0

I wrote the below code to get a string (encrypted) from the user, and I need to use a thread.

        TcpListener TCPListen = new TcpListener(IP2, port);

        TCPListen.Start();


        TcpClient TCP = TCPListen.AcceptTcpClient();


        NetworkStream NetStream = TCP.GetStream();





        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);

Ihe problem is that i should use the thread after the TCPListen.Start(); otherwise will get an error**(Only one usage of each socket address (protocol/network address/port) is normally permitted)**
How can I solve this problem?

  • 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-15T14:37:33+00:00Added an answer on May 15, 2026 at 2:37 pm

    Alternatively to moving the blocking calls to a new thread, you can use use BeginConnect, BeginReceive, BeginSend methods and their corresponding End(Connect | Receive | Send) as outlined here.

    EDIT: RE: question below from OP…
    Instead of calling Connect(), you would call BeginConnect() and provide BeginConnect() a method to call when someone connects (known as a “Callback”). This Callback will get called so that you can do whatever work you need to do. The first thing your code should do is call EndConnect(). The issue is that calling Connect() blocks (ie, halts all code execution on that thread) until it returns. Using the BeginXXX() and EndXXX() side steps this issue. Its really too meaty of a topic to explain in any useful depth here. Study at the MSDN doc linked above. If you have specific questions after spending some time with it, post them back here and I’ll try to answer them. 🙂

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

Sidebar

Related Questions

I just wrote some .NET code to get connection string from the config file.
I mean that I use below code to get html source from url. But
I wrote the code below : 1. MyClass[] origArr=new MyClass[3]; 2. MyClass[] arr1; 3.
I have wrote the code below which was taken from Java How to program
I have wrote below code. import java.io.*; class Test { public static void main(String
I have the code below that I wrote to get rid of a huge
I use the code below and get this error InvalidDataExcption: The magic number in
I wrote the code below to output the figure but still need to figure
When I write the below code, why do I get avaliable Thread number like
In the code below I use mpf_add to add the string representation of two

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.