[C#] Closing Port Connection
Hello, Everyone, =D
I'm Having Some Problems,
I'm using port 91 as my TCP Connection In My C# Application, When I Close The Application The Port is still in use (91).
I Want To Close The Connection With A Button So..
private void button1_Click(object sender, EventArgs e)
{
Close();
Application.ExitThread();
}
I Need It To Close The TCP Connection of Port 91, Thank You, The Only Way I can Use It Is To Restart My Computer So Plz Help, Thanks =D
Re: [C#] Closing Port Connection
QWhat metod are you suing to open them ? ill mess about later if you can tell me if it uses
PHP Code:
new tcp listener();
it should be prety simple
Re: [C#] Closing Port Connection
Quote:
Originally Posted by
razkevin
Ok, I Used -
PHP Code:
public void RequestStop()
{
// set event \"Stop\"
tlsClient.Stop();
ServRunning = false;
}
Then For The Button -
PHP Code:
private void button1_Click(object sender, EventArgs e)
{
// Parse the server's IP address out of the TextBox
IPAddress ipAddr = IPAddress.Parse(txtIp.Text);
// Create a new instance of the ChatServer object
ChatServer mainServer = new ChatServer(ipAddr);
// Hook the StatusChanged event handler to mainServer_StatusChanged
ChatServer.StatusChanged += new StatusChangedEventHandler(mainServer_StatusChanged);
// Start listening for connections
mainServer.RequestStop();
// Show that we started to listen for connections
txtLog.AppendText("Connection Disconnecting....\r\n");
Close();
System.Windows.Forms.Application.ExitThread();
}
hmm tbh id of done it diffrently ^^
but this is mysudgestion from what ive seen of you code to stopiing it
PHP Code:
private void button1_Click(object sender, EventArgs e)
{
// set event \"Stop\"
tlsClient.Stop(); //stops the tcp listener i cant rember how to close ports of the top of my head
ServRunning = false; // db :S
txtLog.AppendText("Connection Disconnecting....\r\n"); // writes to the logs lol
Close(); //closes ? will that even work lol
System.Windows.Forms.Application.ExitThread(); // closes the current thread
}
Re: [C#] Closing Port Connection
My Code Works And tlsClient.Stop(); Will Only Work If You Had mainserver.requeststop()
Since tlsClient.Stop() Is Located In The chatserver.cs...
While
IPAddress ipAddr = IPAddress.Parse(txtIp.Text);
// Create a new instance of the ChatServer object
ChatServer mainServer = new ChatServer(ipAddr);
== chatserver == mainserver..
Thanks Anyways xD
(Contribution To HOLO Chat System xD)
Re: [C#] Closing Port Connection
hmm well unless ive miss read the code why are you createing a new chat server object to stop when you click the button?
Re: [C#] Closing Port Connection
Nope, It's Not Creating A new Chat Server, Just Closing The Element..