//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ // // METHOD : MainWindow() // DESCRIPTION : This method initializes the main window, starts the server // and connects to the client // PARAMETERS : none // RETURNS : none // public MainWindow() { InitializeComponent(); Closing += MainWindow_Close; //Assigns the method to the thread serverListener = new Thread(new ParameterizedThreadStart(ListenToServer)); //Set thread working flag to true continueListen = true; //Start the thread serverListener.Start(stream); try { //Connect TCP client to server client = new TcpClient(server, port); //Setup service stream with client stream = client.GetStream(); } catch (ArgumentNullException Ae) { MessageBox.Show(Ae.ToString()); } catch (SocketException Se) { MessageBox.Show(Se.ToString()); } }
// FUNCTION : MainWindow() // DESCRIPTION : This function sets up the the main window public MainWindow() { InitializeComponent(); Closing += Close_Window; // start thread listening to server listener = new Thread(new ParameterizedThreadStart(ListenForChatServer)); keepListening = true; // start the stream listener.Start(stream); // try catch to catch any exceptions try { // connect the client to the server client = new TcpClient(serverIP, portNumber); // create the stream stream = client.GetStream(); } catch (ArgumentNullException Ae) { MessageBox.Show(Ae.ToString()); } catch (SocketException Se) { MessageBox.Show(Se.ToString()); } }