Socket(IOLoop loop, System.Net.Sockets.Socket socket) : this(loop) { this.socket = socket; this.address = ((IPEndPoint) socket.RemoteEndPoint).Address.ToString (); this.port = ((IPEndPoint) socket.RemoteEndPoint).Port; }
public static void Start(ManosApp application) { if (application == null) { throw new ArgumentNullException("application"); } app = application; app.StartInternal(); started = true; foreach (var ep in listenEndPoints) { var server = new HttpServer(HandleTransaction, IOLoop.CreateSocketStream()); server.Listen(ep.Address.ToString(), ep.Port); servers.Add(server); } foreach (var ep in secureListenEndPoints.Keys) { var keypair = secureListenEndPoints [ep]; var socket = IOLoop.CreateSecureSocket(keypair.Item1, keypair.Item2); var server = new HttpServer(HandleTransaction, socket); server.Listen(ep.Address.ToString(), ep.Port); servers.Add(server); } ioloop.Start(); }
public HttpServer(IOLoop loop, HttpConnectionCallback callback, Socket socket, bool closeOnEnd = false) { this.callback = callback; this.socket = socket; this.closeOnEnd = closeOnEnd; this.IOLoop = loop; }
public UdpReceiver(IOLoop loop, int maxMessageSize) { this.loop = loop; readBuffer = new byte[maxMessageSize]; this.maxMessageSize = maxMessageSize; }
public Timers(Manos.IO.IOLoop loop, int initialSize = 2) { this.loop = loop; freeList = new Queue <int>(initialSize); growWatchers(initialSize); }
public SocketStream(IOLoop loop, Socket sock) : this(loop) { socket = sock; StartTimeout(); address = ((IPEndPoint)socket.RemoteEndPoint).Address.ToString(); port = ((IPEndPoint)socket.RemoteEndPoint).Port; }
public Boundary(IOLoop loop, int maxWorkPerLoop) { asyncWatcher = new AsyncWatcher((LibEvLoop)loop.EventLoop, (l, w, et) => ProcessWork()); asyncWatcher.Start(); workQueue = new ConcurrentQueue <Action> (); this.maxWorkPerLoop = maxWorkPerLoop; }
public Boundary(IOLoop loop, int maxWorkPerLoop) { asyncWatcher = loop.NewAsyncWatcher(ProcessWork); asyncWatcher.Start(); workQueue = new ConcurrentQueue <Action> (); this.maxWorkPerLoop = maxWorkPerLoop; }
public int Run(string app, IList <string> args) { IManosRun mr = Loader.LoadLibrary <IManosRun> (app, new List <string> ()); IOLoop loop = IOLoop.Instance; string [] strargs = new string [args.Count]; for (int i = 0; i < strargs.Length; i++) { strargs [i] = args [i]; } if (mr == null) { Console.WriteLine("Binary {0} has no suitable entry point", app); return(-1); } int ret = mr.Main(strargs); loop.Start(); return(ret); }
public Socket(IOLoop loop) { if (loop == null) throw new ArgumentNullException ("loop"); this.loop = loop; }
public Boundary(IOLoop loop) : this(loop, 18) { }
public Complete(IOLoop loop) { Preconditions.IsNotNull(loop, "IOLoop has not been defined - can't set a timeout"); this.loop = loop; }
public UdpReceiver(IOLoop loop) : this(loop, 128 * 1024) { }
public static int Main(string[] args) { GlobalErrorHandler.Instance.SetGlobalErrorHandler((o, e) => { Console.WriteLine(e.ExceptionObject); IOLoop.Instance.Stop(); Environment.Exit(-1); }); if (args.Length == 0) { Console.Error.WriteLine("node yourdll.dll [args[]]"); return(-1); } string dll = args[0]; if (!dll.EndsWith(".dll")) { dll += ".dll"; } if (!File.Exists(dll)) { Console.Error.WriteLine("dll '{0}' not found", dll); return(-1); } Assembly asy; try { asy = Assembly.LoadFile(args[0]); } catch (Exception ex) { Console.Error.WriteLine("failed to load dll '{0}'. Exception was {1}", dll, ex.Message); return(-1); } Type[] types = asy.GetTypes(); INodeProgram program = null; foreach (var type in types) { if (typeof(INodeProgram).IsAssignableFrom(type)) { try { program = (INodeProgram)asy.CreateInstance(type.FullName); break; } catch (Exception ex) { Console.Error.WriteLine("failed to type '{0}'. Exception was {1}", type.FullName, ex.Message); return(-1); } } } if (program == null) { Console.Error.WriteLine("Assembly '{0}' doesn't appear to have a INodeProgram type", asy.FullName); return(-1); } string[] progArgs = new string[args.Length - 1]; for (int i = 1; i < args.Length; i++) { progArgs[i] = args[i]; } IOLoop loop = IOLoop.Instance; int retCode = 0; Manos.Timeout t = new Manos.Timeout(TimeSpan.FromSeconds(1), RepeatBehavior.Single, null, (a, o) => { Console.WriteLine("Starting program"); try { retCode = program.Main(progArgs); } catch (Exception ex) { Console.Error.WriteLine("NodeProgram failed on startup {0}", ex); loop.Stop(); retCode = -1; } if (retCode != 0) { loop.Stop(); } }); loop.AddTimeout(t); loop.Start(); return(retCode); }
public HttpServer(IOLoop ioloop, bool closeOnEnd = false) { this.ioloop = ioloop; this.closeOnEnd = closeOnEnd; }
public ManagedLoop(IOLoop owner) { this.owner = owner; }
public SocketStream(IOLoop loop) { this.loop = loop; }
public HttpServer(HttpConnectionCallback callback, IOLoop ioloop, bool closeOnEnd = false) { this.callback = callback; this.ioloop = ioloop; this.closeOnEnd = closeOnEnd; }
public HttpServer(HttpConnectionCallback callback, IOLoop ioloop) { this.callback = callback; this.ioloop = ioloop; }