private void clientListBox_SelectedIndexChanged(object sender, System.EventArgs e) { selectedClient = (clientInfo)clientInformation[clientListBox.SelectedIndex]; machineNameTextBox.Text = selectedClient.MachineName; userNameTextBox.Text = selectedClient.UserName; ipAddressTextBox.Text = selectedClient.IpAddress; portTextBox.Text = selectedClient.PortNumber.ToString(); protocolTextBox.Text = selectedClient.ConnectedSocket.ProtocolType.ToString(); if (radioButton1.Checked) { serviceListBox.Items.Clear(); IEnumerator en = selectedClient.ProcessList.GetEnumerator(); while (en.MoveNext()) { ProcessObject processObject = (ProcessObject)en.Current; serviceListBox.Items.Add(processObject.ProcessName); } } else if (radioButton2.Checked) { serviceListBox.Items.Clear(); IEnumerator en = selectedClient.ServiceList.GetEnumerator(); while (en.MoveNext()) { ServiceObject serviceObject = (ServiceObject)en.Current; serviceListBox.Items.Add(serviceObject.DisplayName); } } }
/// <summary> /// Event handler for new client connection /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void clientConnectionHandler(object sender, serverListenerArgs e) { clientInfo c = e.ClientInfo; clientInformation.Add(c); //clientListBox.Items.Add(c.ConnectedSocket.RemoteEndPoint.ToString()); clientListBox.Items.Add(c.MachineName); //c.getMachineName(); }
///<summary> /// This method is a starting point of listener thread which continously listens for new clients /// and when a client arrives starts a new thread to handle that client ///</summary> public void server_listen() { while (running) { try { Socket sock = server_socket.AcceptSocket(); // Console.WriteLine("Connected to Server "+sock.RemoteEndPoint); clientInfo clt = new clientInfo(sock); onClientSignal(this, new serverListenerArgs(clt)); //clt.getMachineName(); } catch (Exception e) { throw new Exception("Error Occurred while listening for clients "); } } }
public serverListenerArgs(clientInfo cltinfo) : base() { this.clientinfo = cltinfo; }