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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T05:42:34+00:00 2026-06-12T05:42:34+00:00

I am developping an application in C# Net framework 2.0. It is basicly a

  • 0

I am developping an application in C# Net framework 2.0.
It is basicly a application with a tcp client class.
the application connects to my server which is a basic ruby tcp server
it stays for 4 hours then get disconnected

class TelnetConnection
{
TcpClient tcpSocket;
int TimeOutMs = 400;
static string host = null;
static int prt = 0;
static int timetorec = 10; //sec

public TelnetConnection(string Hostname, int Port)
{
    host = Hostname;
    prt = Port;
    try
    {
        tcpSocket = new TcpClient(Hostname, Port);
    }
    catch (Exception x)
    {
        Console.WriteLine(x.Message)
    }
}

public void reconnect(int sec)
{
    try
    {
        System.Threading.Thread.Sleep(sec * 1000); //10sec then retry
        tcpSocket = new TcpClient(host, prt);
    }
    catch (Exception x)
    {
        Console.WriteLine(x.Message)
    }
}

public string Login(string Username, string Password, int LoginTimeOutMs)
{
    int oldTimeOutMs = TimeOutMs;
    TimeOutMs = LoginTimeOutMs;
    string s = Read();
    if (!s.TrimEnd().EndsWith(":"))
        throw new Exception("Failed to connect : no login prompt");
    WriteLine(Username);

    s += Read();
    if (!s.TrimEnd().EndsWith(":"))
        throw new Exception("Failed to connect : no password prompt");
    WriteLine(Password);

    s += Read();
    TimeOutMs = oldTimeOutMs;
    return s;
}



public string Read()
{
    try
    {
        if (!tcpSocket.Connected) return null;
        StringBuilder sb = new StringBuilder();
        do
        {
            Parse(sb);
            System.Threading.Thread.Sleep(TimeOutMs);
        } while (tcpSocket.Available > 0);
        return sb.ToString();

    }
    catch (Exception) { return null; }
}





protected override void OnStart(string[] args)
{
    System.Runtime.Remoting.Lifetime.LifetimeServices.LeaseTime = TimeSpan.MaxValue;
    while (tc.IsConnected)
    {
        Thread.Sleep(120);
        what(tc.Read());
    }
}



static void what(string w)
{
    if (w == "Example")
    {
        //DO
    }
}
}

Please help i have tried tcp client instaid but the same thing
application should stay connected at all time RUBYCODE

require 'socket'      # Sockets are in standard library

hostname = 'localhost'
port = 2000

s = TCPSocket.open(host, port)

while line = s.gets   # Read lines from the socket
  puts line.chop      # And print with platform line terminator
end

and repeat the ruby its just an example of socket am using

  • 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-12T05:42:35+00:00Added an answer on June 12, 2026 at 5:42 am

    You’ll need to send some data periodically to keep firewalls and NAT devices from timing out their entries for the connection.

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

Sidebar

Related Questions

I am developping a web application by using the ASP .NET MVC 3 framework.
We are currently developping an application using XmlSerializer from the .NET framework. Here is
I am developping a web application by using the ASP .NET MVC 3 framework.
I'm developing an application targeting .NET Framework 2.0 using C# for which I need
I am developing a C# application using .NET Framework 4.0 in VS2010. It is
I am developing a C# application with .NET Framework 2.0. The problem is, that
What is difference in developing applications using .Net Framework, Asp.net and developing application in
I am currently developing a web application in ASP.NET Framework 4 and I am
We are currently building the framework for developing a C# .net application using visual
I am developing an ASP.Net MVC 3 Web application with Entity Framework 4.1 and

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.