Hey folks!! Hope you can help me with my client code. Först I debugg the Server wich is an consoleapplication and the server starts, secondly I debugg the Client, I put a nickname value to the nickNameTextBox and click on Connect (button2) the compiler stops at this code line
from the button 2 handler - unless you have pressed Button1 first, the connection has not been established and it will likely throw an exception - probably the one you are complaining about.
Personally, I would have a "Connect" method, which checked if you are connected and does so if not - and call it from both click events. (I would probably also make it return the stream instead of using a class level variable directly in the two event handlers).
If you get an email telling you that you can catch Swine Flu from tinned pork then just delete it. It's Spam.
Thank you mate I appreciate your help, I changed it to this code, the reason I commented out
because the compiler stops there when I debugg telling me that a socket is already connected, now the compiler runs withour errors but the server consoleAppplication doesn't receive any msg at all when I send it from sendTextBox..
privatevoid button1_Click(object sender, EventArgs e)
if (serverStream == null)
MessageBox.Show("Please connect to a server.");
readData = "Conected to Chat Server ...";
serverStream = clientSocket.GetStream();
byte outStream = System.Text.Encoding.ASCII.GetBytes(sendTextBox.Text + "$");
serverStream.Write(outStream, 0, outStream.Length);
Thread ctThread = new Thread(getMessage);
The compiler stops on this code under the getMessage method
"Failed to read data from the transport connection: An existing connection was forced to close by the remote host." It havens because I closed the Server... Anyway this project is driving me crazy man I can't see why it's not working and the Server doesn't get and show the string on the server prompt from the Client
Last Visit: 31-Dec-99 19:00 Last Update: 9-Dec-16 19:30