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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T18:05:33+00:00 2026-06-12T18:05:33+00:00

Trying to write a simple bit of code to connect to an IMAP server

  • 0

Trying to write a simple bit of code to connect to an IMAP server using StreamSocket. It reads the server connect response, but then it won’t read anything else.

    private async void TCPTest(string hostName, string port)
    {
        status.Text = "start of TCPTest";

        StreamSocket socket = new StreamSocket();
        await socket.ConnectAsync(new HostName(hostName), port);

        string senddata = "A001 login uuu ppp";

        status.Text += "\n first reading...";
        DataReader reader = new DataReader(socket.InputStream);
        reader.InputStreamOptions = InputStreamOptions.Partial;
        await reader.LoadAsync(1024);
        string data = reader.ReadString(reader.UnconsumedBufferLength);
        status.Text += "\n > read " + data;

        status.Text += "\n writing...";
        writer = new DataWriter(socket.OutputStream);
        writer.WriteString(senddata);
        await writer.StoreAsync();
        status.Text += "\n > wrote " + sendata;

        status.Text += "\n second reading...";
        writer = new DataWriter(socket.OutputStream);
        await reader.LoadAsync(1024);
        string data2 = reader.ReadString(reader.UnconsumedBufferLength);
        status.Text += "\n >" + data2;

        status.Text += "\n end of TCPTest";
    }

This is the output I get.

start of TCPTest
first reading...
> read * OK mydomain.com IMAP4rev1 MDaemon 13.0.1 ready
writing...
> wrote A001 login uuu ppp
second reading... 

The app never gets any further than this. There’s no error, it just hangs. Am I doing something fundamentally wrong here? My code is the same (more or less) as the StreamSocket example on MSDN

  • 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-12T18:05:34+00:00Added an answer on June 12, 2026 at 6:05 pm

    Turns out I wasn’t terminating my command. Adding Environment.Newline to the end solved things.

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

Sidebar

Related Questions

I'm trying to write a simple code in Java to connect to a memcache
I'm trying to write some code for simple complex number manipulation. I'm using a
I'm trying to write simple proxy server for some purpose. In it I use
I trying to write a simple function to call unmanaged code from managed code.
I am trying to write some simple code which will read a text file
I am trying to write a simple application to interact with NFC tags, but
I'm trying to write a simple program using WinSnmp in C++. There is very
I'm trying to write a simple program to change my desktop wallpaper. I'm using
I've spent all morning trying to write what I thought was a simple bit
I'm trying to write a simple game to teach some basic Welsh using the

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.