ISocketListener.cs 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using SuperSocket.SocketBase;
  6. using SuperSocket.SocketBase.Config;
  7. using System.Net.Sockets;
  8. using System.Net;
  9. namespace SuperSocket.SocketEngine
  10. {
  11. delegate void ErrorHandler(ISocketListener listener, Exception e);
  12. delegate void NewClientAcceptHandler(ISocketListener listener, Socket client, object state);
  13. /// <summary>
  14. /// The interface for socket listener
  15. /// </summary>
  16. interface ISocketListener
  17. {
  18. /// <summary>
  19. /// Gets the info of listener
  20. /// </summary>
  21. ListenerInfo Info { get; }
  22. /// <summary>
  23. /// Gets the end point the listener is working on
  24. /// </summary>
  25. IPEndPoint EndPoint { get; }
  26. /// <summary>
  27. /// Starts to listen
  28. /// </summary>
  29. /// <param name="config">The server config.</param>
  30. /// <returns></returns>
  31. bool Start(IServerConfig config);
  32. /// <summary>
  33. /// Stops listening
  34. /// </summary>
  35. void Stop();
  36. /// <summary>
  37. /// Occurs when new client accepted.
  38. /// </summary>
  39. event NewClientAcceptHandler NewClientAccepted;
  40. /// <summary>
  41. /// Occurs when error got.
  42. /// </summary>
  43. event ErrorHandler Error;
  44. /// <summary>
  45. /// Occurs when [stopped].
  46. /// </summary>
  47. event EventHandler Stopped;
  48. }
  49. }