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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T18:57:32+00:00 2026-05-29T18:57:32+00:00

Thanks for reading and answering in advance! I wrote a simple C# program that

  • 0

Thanks for reading and answering in advance!

I wrote a simple C# program that connects via sockets with a third-party tool. Whenever I send a string longer than 1024 characters, the third-party software throws an error. Now I am trying to find out if this is a problem of my socket code or one of the other software (EnergyPlus).

It is only a few lines of code, and if anyone has suggestions, they would be highly appreciated!

using System.IO;
using System.Net;
using System.Net.Sockets;
...
private int port = 1410;
private TcpListener listener;
private Stream s;
private StreamReader sr;
private StreamWriter sw;
private Socket soc;
...

Here it really starts:

listener = new TcpListener(port);
listener.Start();
soc = listener.AcceptSocket();

// now, the other program connects

soc.SetSocketOption(SocketOptionLevel.Socket,
        SocketOptionName.ReceiveTimeout, 10000);

s = new NetworkStream(soc);

sr = new StreamReader(s);
sw = new StreamWriter(s);
sw.AutoFlush = true; // enable automatic flushing

sw.WriteLine("more or less than 1024 characters");

...

This is the code I use. Anything I forgot? Anything I should take care of?
I am glad about any suggestions.

The error I get from E+ is the following:

ExternalInterface: Socket communication received error value " 1" at time = 0.00 hours.
ExternalInterface: Flag from server " 0".
  • 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-29T18:57:33+00:00Added an answer on May 29, 2026 at 6:57 pm

    Yu need to look at the specification defined by EnergyPlus; any socket communication needs rules. There are two obvious options here:

    1. you aren’t following the rules (maybe it is limited length, or maybe you need to write special marker bytes for this scenario)
    2. their server code doesn’t implement the specification correctly (biggest causes are: buffer issues, or: assuming a logical frame arrives in a single network packet)

    Actually, I find it interesting that it is doing anything yet, as there is no obvious “frame” there; TCP is a stream, so you ususally need frames to divide logical messages. This usually means one of:

    • a length prefix, with or without other header data
    • a cr/lf/crlf terminator (or other terminator), usually for text-based protocols
    • closing the socket (the ultimate terminator)

    You do none of those, so in any server I write, that would be an incomplete message until something else happens. It sounds text-based; I’d try adding a cr/lf/crlf

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

Sidebar

Related Questions

Thanks for reading this. I would have thought it would be as simple as
Thanks in Advance for reading and answer this question. I got button in asp
thanks for reading! Here's what I'm up to. I'm writing a WordPress plugin that
Thanks for reading. I've noticed that if I have a page that has one
thanks for reading this. I was wondering if I have some simple authentication system
Thanks for reading my question. I have a website that uses PHP for a
Thanks for reading. On my homepage I've made an script that loops thru a
Thanks for reading. I'm a bit new to jQuery, and am trying to make
Thanks for reading this. I am dynamically generating some data which includes a select
Thanks for reading this. I have markup similar to what is below. 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.