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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T19:39:15+00:00 2026-05-27T19:39:15+00:00

Lately, when using my TCP/IP Server and Client, I has noticed that they both

  • 0

Lately, when using my TCP/IP Server and Client, I has noticed that they both stay open in Processes after I close them.

I fixed the Client staying open by disposing the socket to the server, which closes down all asynchronous threads in the background of my framework.

However, when trying to do so with the server, no matter what I do, the process stays open.

ASSUMING that the TCP/IP server is handling it’s own stuff, is there ANY thing else in this code that would keep the process open?

EDIT: UPDATE:
If I put a breakpoint after the Application.Run(new ServerForm()) line in Program.cs, it will break once I press exit or call Application.Exit().

I don’t know what it is hanging up the program but it’s not exiting the Main.

namespace ChatServer
{
    public partial class ServerForm : Form
    {
        private NetLib.Server _server = new NetLib.Server();
        public delegate void ClientConnection(ServerNetworkState ns);

    public ServerForm()
    {
        InitializeComponent();
    }

    private void ServerForm_Load(object sender, EventArgs e)
    {
        //Set up server IP and Port #.
        _server.Ip = "127.0.0.1";
        _server.Port = 5001;
        //Setup events for success/error checking
        _server.NewConnection += new NetLib.Server.NetworkStateEventHandler(_server_NewConnection);
        _server.Started += new NetLib.Server.ServerEventHandler(_server_Started);
        _server.Initialized += new NetLib.Server.ServerEventHandler(_server_Initialized);
        _server.BindFailure += new NetLib.Server.ServerEventHandler(_server_BindFailure);
        _server.BindSuccess += new NetLib.Server.ServerEventHandler(_server_BindSuccess);

        //Initialize Server and add neccesary commands
        _server.Initialize();

        //Clients will call sendmessage on the server,
        //and the server will send the message to the neccesary clients.
        _server.MessageEncoder.FriendlyCommands.Add("sendmessage", SendMessage);
    }

    public void SendMessage(short sender, short[] recipients, string text)
    {
        _server.MessagePump.Enqueue(new Packet(-1, recipients, "receivemessage", text));
    }

    void _server_BindSuccess()
    {
        //Log Bind Success at DateTime.Now
    }

    void _server_BindFailure()
    {
        //Log Bind Failure at DateTime.Now
    }

    void _server_Initialized()
    {
        //Log Initialized at DateTime.Now
    }

    void _server_Started()
    {
        //Log Started at DateTime.Now
    }

    void _server_NewConnection(NetLib.ServerNetworkState ns)
    {
        //Log New Connection with ns.Ip at DateTime.Now
        BeginInvoke(new ClientConnection(AddClientToControl), ns);            
    }

    private void AddClientToControl(NetLib.ServerNetworkState ns)
    {
        listBox1.Items.Add("ID: " + ns.Id + " IP: " + ns.Ip);
    }

    private void startServer_Click(object sender, EventArgs e)
    {
        _server.Start();
    }

    private void ServerForm_FormClosing(object sender, FormClosingEventArgs e)
    {
        _server.Dispose();
    }
}

}

  • 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-27T19:39:15+00:00Added an answer on May 27, 2026 at 7:39 pm

    Turns out that there was one thread that was overlooked in the library. Thank you all for trying to trying to find out if there was anything above that would cause the problem.

    To answer the question: Nothing in the code above was causing the issue stated. It was a thread that was opened in the Netlib library and was never handled when disposing and closing any connection that was open.

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

Sidebar

Related Questions

I've been doing quite a bit of debugging of managed applications lately using both
I've been using PostgreSQL a little bit lately, and one of the things that
Lately I've been using client-side jQuery scripts to fill in forms when users edit
I've been using applicative (and alternative) a fair bit lately, and one thing that
I am using Eclipse 3.6 Helios on Windows. Lately, my Eclipse install has been
Lately, I've decided to start using Perl::Critic more often on my code. After programming
Lately when I have been looking at other code, I have noticed that I
I was using a hosting to run my site, lately it has been working
I've been using virtualenv lately while developing in python. I like the idea of
I've been using RhinoMocks lately but I keep running into an issue. If I

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.