void CModule::ListSockets() { if (m_sSockets.empty()) { PutModule("You have no open sockets."); return; } CTable Table; Table.AddColumn("Name"); Table.AddColumn("State"); Table.AddColumn("LocalPort"); Table.AddColumn("SSL"); Table.AddColumn("RemoteIP"); Table.AddColumn("RemotePort"); set<CSocket*>::iterator it; for (it = m_sSockets.begin(); it != m_sSockets.end(); ++it) { CSocket* pSocket = *it; Table.AddRow(); Table.SetCell("Name", pSocket->GetSockName()); if (pSocket->GetType() == CSocket::LISTENER) { Table.SetCell("State", "Listening"); } else { Table.SetCell("State", (pSocket->IsConnected() ? "Connected" : "")); } Table.SetCell("LocalPort", CString(pSocket->GetLocalPort())); Table.SetCell("SSL", (pSocket->GetSSL() ? "yes" : "no")); Table.SetCell("RemoteIP", pSocket->GetRemoteIP()); Table.SetCell("RemotePort", (pSocket->GetRemotePort()) ? CString(pSocket->GetRemotePort()) : CString("")); } PutModule(Table); }