/src/Fijo.Net/Services/Socket/SocketService.cs

https://bitbucket.org/Fijo/clusterconcept · C# · 25 lines · 22 code · 3 blank · 0 comment · 0 complexity · 063f776f7f78f4fe6db2cfbe84014e17 MD5 · raw file

  1. using System.IO;
  2. using Fijo.Net.Services.Socket.Streams;
  3. using FijoCore.Infrastructure.LightContrib.Default.Service.Out.Interface;
  4. using FijoCore.Infrastructure.LightContrib.Service.ExecptionFormatter;
  5. using JetBrains.Annotations;
  6. using SNet = System.Net.Sockets;
  7. namespace Fijo.Net.Services.Socket {
  8. [UsedImplicitly]
  9. public class SocketService : ISocketService {
  10. private readonly IOut _out;
  11. private readonly IExceptionFormatter _exceptionFormatter;
  12. public SocketService(IOut @out, IExceptionFormatter exceptionFormatter) {
  13. _out = @out;
  14. _exceptionFormatter = exceptionFormatter;
  15. }
  16. #region Implementation of ISocketService
  17. public Stream GetStream(SNet.Socket socket) {
  18. return new SocketStream(new SNet.NetworkStream(socket), _out, _exceptionFormatter);
  19. }
  20. #endregion
  21. }
  22. }