netstat -a -n
Then find the IP:Port combo you want to count and modify the following command to get the count:
netstat -a -n | find /c "<ip:port>"
Example:
netstat -a -n | find /c "127.0.0.1:1935"
netstat -a -n
netstat -a -n | find /c "<ip:port>"
netstat -a -n | find /c "127.0.0.1:1935"
namespace Mvc3Ninject.Utility
{
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web.Mvc;
using Ninject;
[System.Diagnostics.DebuggerStepThrough]
public class NinjectResolver : IDependencyResolver
{
private static IKernel kernel;
public NinjectResolver()
{
kernel = new StandardKernel();
RegisterServices(kernel);
}
public NinjectResolver(IKernel myKernel)
{
kernel = myKernel;
RegisterServices(kernel);
}
public static void RegisterServices(IKernel kernel)
{
//kernel.Bind<IThingRepository>().To<SqlThingRepository>();
}
public object GetService(Type serviceType)
{
return kernel.TryGet(serviceType);
}
public IEnumerable<object> GetServices(Type serviceType)
{
return kernel.GetAll(serviceType);
}
}
}
//// Tell ASP.NET MVC 3 to use our Ninject DI Container MvcServiceLocator.SetCurrent(new NinjectServiceLocator(_container));
//// Tell ASP.NET MVC 3 to use our Ninject DI Container DependencyResolver.SetResolver(new NinjectResolver(_container));
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Data.Objects;
using System.Data.Objects.DataClasses;
using System.Data.Metadata.Edm;
using System.Data.Entity;
namespace Web.Infrastructure.Storage
{
public class EFCFSession : ISession
{
DbContext _context;
public EFCFSession(DbContext context)
{
_context = context;
}
public void CommitChanges() {
_context.SaveChanges();
}
public void Delete<T>(System.Linq.Expressions.Expression<Func<T, bool>> expression) where T: class, new() {
var query = All<T>().Where(expression);
foreach (var item in query) {
Delete(item);
}
}
public void Delete<T>(T item) where T: class, new() {
_context.Set<T>().Remove(item);
}
public void DeleteAll<T>() where T: class, new() {
var query = All<T>();
foreach (var item in query) {
Delete(item);
}
}
public void Dispose() {
_context.Dispose();
}
public T Single<T>(System.Linq.Expressions.Expression<Func<T, bool>> expression) where T: class, new() {
return All<T>().FirstOrDefault(expression);
}
public IQueryable<T> All<T>() where T: class, new() {
return _context.Set<T>().AsQueryable<T>();
}
public void Add<T>(T item) where T: class, new() {
_context.Set<T>().Add(item);
}
public void Add<T>(IEnumerable<T> items) where T: class, new() {
foreach (var item in items) {
Add(item);
}
}
public void Update<T>(T item) where T: class, new() {
//nothing needed here
}
}
}
using System;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using System.Web.Routing;
using Ninject.Web.Mvc;
using Ninject;
using Ninject.Modules;
using Site.Infrastructure.Logging;
using Web.Infrastructure.Authentication;
using Web.Infrastructure.Reporting;
using Web.Infrastructure.Storage;
using Web.Model;
namespace Web
{
// Note: For instructions on enabling IIS6 or IIS7 classic mode,
// visit http://go.microsoft.com/?LinkId=9394801
public class MvcApplication : NinjectHttpApplication
{
public static ISession Session
{
get
{
return _container.Get<ISession>();
}
}
public static void RegisterRoutes(RouteCollection routes)
{
routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
routes.IgnoreRoute("favicon.ico");
routes.MapRoute(
"Login", // Route name
"login", // URL with parameters
new { controller = "Session", action = "Create" } // Parameter defaults
);
routes.MapRoute(
"Logout", // Route name
"logout", // URL with parameters
new { controller = "Session", action = "Delete" } // Parameter defaults
);
routes.MapRoute(
"Default", // Route name
"{controller}/{action}/{id}", // URL with parameters
new { controller = "Home", action = "Index", id = UrlParameter.Optional } // Parameter defaults
);
}
protected override void OnApplicationStarted()
{
Logger.Info("App is starting");
//Database.SetInitializer<SiteDB>(new AlwaysRecreateDatabase<SiteDB>());
AreaRegistration.RegisterAllAreas();
RegisterRoutes(RouteTable.Routes);
//ControllerBuilder.Current.SetControllerFactory(new NinjectControllerFactory(Container));
}
protected void Application_End()
{
Logger.Info("App is shutting down");
}
protected void Application_Error()
{
Exception lastException = Server.GetLastError();
Logger.Fatal(lastException);
}
/// <summary>
/// IoC stuff below
/// </summary>
/// <returns></returns>
protected override IKernel CreateKernel()
{
return Container;
}
internal class SiteModule : NinjectModule
{
public override void Load()
{
//a typical binding
Bind<ILogger>().To<NLogLogger>().InSingletonScope();
//Bind<INoSqlServer>().To<DB4OServer>().InSingletonScope();
//Bind<ISession>().To<Db4oSession>().InRequestScope();
//You can use the SimpleRepository to build out your database
//it runs "Auto Migrations" - changing your schema on the fly for you
//should you change your model. You can switch it out as you need.
//http://subsonicproject.com/docs/Using_SimpleRepository
Bind<ISession>().To<SiteEFSession>();
Bind<IReporting>().To<ReportingSession>();
Bind<IAuthenticationService>().To<UserAuthenticationService>();
}
}
public ILogger Logger
{
get
{
return Container.Get<ILogger>();
}
}
static IKernel _container;
public static IKernel Container
{
get
{
if (_container == null)
{
_container = new StandardKernel(new SiteModule());
}
return _container;
}
}
}
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using System.Web.Routing;
using Ninject;
using Ninject.Modules;
using Site.Infrastructure.Logging;
using Web.Infrastructure.Authentication;
using Web.Infrastructure.Reporting;
using Web.Infrastructure.Storage;
using Web.Model;
using Mvc3Ninject.Utility;
namespace Web
{
// Note: For instructions on enabling IIS6 or IIS7 classic mode,
// visit http://go.microsoft.com/?LinkId=9394801
public class MvcApplication : HttpApplication
{
public static void RegisterGlobalFilters(GlobalFilterCollection filters)
{
filters.Add(new HandleErrorAttribute());
}
public static void RegisterRoutes(RouteCollection routes)
{
routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
routes.IgnoreRoute("favicon.ico");
routes.MapRoute(
"Login", // Route name
"login", // URL with parameters
new { controller = "Session", action = "Create" } // Parameter defaults
);
routes.MapRoute(
"Logout", // Route name
"logout", // URL with parameters
new { controller = "Session", action = "Delete" } // Parameter defaults
);
routes.MapRoute(
"Default", // Route name
"{controller}/{action}/{id}", // URL with parameters
new { controller = "Home", action = "Index", id = UrlParameter.Optional } // Parameter defaults
);
}
public static void RegisterServices(IKernel kernel)
{
//a typical binding
kernel.Bind<ILogger>().To<NLogLogger>().InSingletonScope();
//Bind<INoSqlServer>().To<DB4OServer>().InSingletonScope();
//Bind<ISession>().To<Db4oSession>().InRequestScope();
//You can use the SimpleRepository to build out your database
//it runs "Auto Migrations" - changing your schema on the fly for you
//should you change your model. You can switch it out as you need.
//http://subsonicproject.com/docs/Using_SimpleRepository
kernel.Bind<ISession>().To<SiteEFSession>();
kernel.Bind<IReporting>().To<ReportingSession>();
kernel.Bind<IAuthenticationService>().To<UserAuthenticationService>();
}
public void SetupDependencyInjection()
{
// Create Ninject DI Kernel
_container = new StandardKernel();
//// Register services with our Ninject DI Container
RegisterServices(_container);
//// Tell ASP.NET MVC 3 to use our Ninject DI Container
MvcServiceLocator.SetCurrent(new NinjectServiceLocator(_container));
}
void Application_Start()
{
SetupDependencyInjection();
RegisterGlobalFilters(GlobalFilters.Filters);
RegisterRoutes(RouteTable.Routes);
Logger.Info("App is starting");
}
protected void Application_End()
{
Logger.Info("App is shutting down");
}
protected void Application_Error()
{
Exception lastException = Server.GetLastError();
Logger.Fatal(lastException);
}
public ILogger Logger
{
get
{
return Container.Get<ILogger>();
}
}
static IKernel _container;
public static IKernel Container
{
get
{
return _container;
}
}
}
}kernel.Bind<IControllerFactory>().To<Ninject.Web.Mvc.NinjectControllerFactory>();
kernel.Bind<IControllerFactory>().To<DefaultControllerFactory>();
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using System.Web.Routing;
using Ninject;
using Ninject.Modules;
using Site.Infrastructure.Logging;
using Web.Infrastructure.Authentication;
using Web.Infrastructure.Reporting;
using Web.Infrastructure.Storage;
using Web.Model;
using Mvc3Ninject.Utility;
namespace Web
{
// Note: For instructions on enabling IIS6 or IIS7 classic mode,
// visit http://go.microsoft.com/?LinkId=9394801
public class MvcApplication : HttpApplication
{
public static void RegisterGlobalFilters(GlobalFilterCollection filters)
{
filters.Add(new HandleErrorAttribute());
}
public static void RegisterRoutes(RouteCollection routes)
{
routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
routes.IgnoreRoute("favicon.ico");
routes.MapRoute(
"Login", // Route name
"login", // URL with parameters
new { controller = "Session", action = "Create" } // Parameter defaults
);
routes.MapRoute(
"Logout", // Route name
"logout", // URL with parameters
new { controller = "Session", action = "Delete" } // Parameter defaults
);
routes.MapRoute(
"Default", // Route name
"{controller}/{action}/{id}", // URL with parameters
new { controller = "Home", action = "Index", id = UrlParameter.Optional } // Parameter defaults
);
}
public static void RegisterServices(IKernel kernel)
{
kernel.Bind<IControllerFactory>().To<DefaultControllerFactory>();
//a typical binding
kernel.Bind<ILogger>().To<NLogLogger>().InSingletonScope();
//Bind<INoSqlServer>().To<DB4OServer>().InSingletonScope();
//Bind<ISession>().To<Db4oSession>().InRequestScope();
//You can use the SimpleRepository to build out your database
//it runs "Auto Migrations" - changing your schema on the fly for you
//should you change your model. You can switch it out as you need.
//http://subsonicproject.com/docs/Using_SimpleRepository
kernel.Bind<ISession>().To<SiteEFSession>();
kernel.Bind<IReporting>().To<ReportingSession>();
kernel.Bind<IAuthenticationService>().To<UserAuthenticationService>();
}
public void SetupDependencyInjection()
{
// Create Ninject DI Kernel
_container = new StandardKernel();
//// Register services with our Ninject DI Container
RegisterServices(_container);
//// Tell ASP.NET MVC 3 to use our Ninject DI Container
MvcServiceLocator.SetCurrent(new NinjectServiceLocator(_container));
}
void Application_Start()
{
SetupDependencyInjection();
RegisterGlobalFilters(GlobalFilters.Filters);
RegisterRoutes(RouteTable.Routes);
Logger.Info("App is starting");
}
protected void Application_End()
{
Logger.Info("App is shutting down");
}
protected void Application_Error()
{
Exception lastException = Server.GetLastError();
Logger.Fatal(lastException);
}
public ILogger Logger
{
get
{
return Container.Get<ILogger>();
}
}
static IKernel _container;
public static IKernel Container
{
get
{
return _container;
}
}
}
}