PushSocket.cs 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. using System;
  2. using NetMQ.Core;
  3. namespace NetMQ.Sockets
  4. {
  5. /// <summary>
  6. /// A PushSocket is a NetMQSocket intended to be used as the "Push" part of the Push-Pull pattern.
  7. /// This will "push" messages to be pulled by the "pull" socket.
  8. /// </summary>
  9. public class PushSocket : NetMQSocket
  10. {
  11. /// <summary>
  12. /// Create a new PushSocket and attach socket to zero or more endpoints.
  13. /// </summary>
  14. /// <param name="connectionString">List of NetMQ endpoints, separated by commas and prefixed by '@' (to bind the socket) or '>' (to connect the socket).
  15. /// Default action is connect (if endpoint doesn't start with '@' or '>')</param>
  16. /// <example><code>var socket = new PushSocket(">tcp://127.0.0.1:5555,@tcp://127.0.0.1:55556");</code></example>
  17. public PushSocket(string? connectionString = null) : base(ZmqSocketType.Push, connectionString, DefaultAction.Connect)
  18. {
  19. }
  20. /// <summary>
  21. /// Create a new PushSocket based upon the given SocketBase.
  22. /// </summary>
  23. /// <param name="socketHandle">the SocketBase to create the new socket from</param>
  24. internal PushSocket(SocketBase socketHandle)
  25. : base(socketHandle)
  26. {
  27. }
  28. /// <summary><see cref="PushSocket"/> doesn't support sending, so this override throws <see cref="NotSupportedException"/>.</summary>
  29. /// <exception cref="NotSupportedException">Receive is not supported.</exception>
  30. public override bool TryReceive(ref Msg msg, TimeSpan timeout)
  31. {
  32. throw new NotSupportedException("PushSocket doesn't support receiving");
  33. }
  34. }
  35. }