Coder Social home page Coder Social logo

exzmq's Introduction

exzmq

ZeroMQ 3.1 for Elixir

Build Status

Status

  • This project is a work in progress.
  • It is not ready for production use yet.
  • Contributions are welcome

Examples

defmodule ServerExample do

  def main do
    {:ok, socket} = Exzmq.server("tcp://127.0.0.1:5555")
    socket |> receive
  end
  
  defp receive(socket) do
    message = socket |> Exzmq.recv
    IO.puts "Received: #{inspect message}"
    socket |> receive
  end

end

defmodule ClientExample do

  def main do
    {:ok, socket} = Exzmq.client("tcp://127.0.0.1:5555")
    socket |> Exzmq.send("Hello")
  end

end	

Contribution

This projects uses the C4.1 process.

License

The project is released under the MPL 2.0 license http://mozilla.org/MPL/2.0/.

exzmq's People

Contributors

benjamintanweihao avatar bluca avatar c-rack avatar hintjens avatar opedroso avatar plemanach avatar protochron avatar taotetek avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

exzmq's Issues

Lots of "PROGRESS REPORT"

like this:

=PROGRESS REPORT==== 5-May-2014::11:13:51 ===
          supervisor: {local,ranch_sup}
             started: [{pid,<0.119.0>},
                       {name,{ranch_listener_sup,my_http_listener}},
                       {mfargs,
                        {ranch_listener_sup,start_link,
                         [my_http_listener,100,ranch_tcp,
                          [{port,19000}],
                          cowboy_protocol,
                          [{env,
                            [{dispatch,
                              [{'_',[],
                                [{[],[],'Elixir.WebSocketHandler',
                                  []}]}]}]}]]}},
                       {restart_type,permanent},
                       {shutdown,5000},
                       {child_type,supervisor}]

=PROGRESS REPORT==== 5-May-2014::11:13:51 ===
         application: bigdata_ws
          started_at: nonode@nohost

Should remove SASL?

Unit tests fail (Elixir 1.1.1)

Just installed elixir the first time and wanted to get right into using it with exzmq. Noticed that the tests fail

elixir -v
Elixir 1.1.1




mix test
......

  1) test open a rep socket and wait time out (ExzmqTest)
     test/exzmp_test.exs:117
         ** (MatchError) no match of right hand side value: {:error, {{:badmatch, {:error, :eaddrinuse}},     [{:gen_listener_tcp, :init, 1, [file: 'src/gen_listener_tcp.erl', line: 101]}, {:gen_server, :init_it, 6, [file:     'gen_server.erl', line: 328]}, {:proc_lib, :init_p_do_apply, 3, [file: 'proc_lib.erl', line: 240]}]}}
     stacktrace:
   test/exzmp_test.exs:119
...

GenFSM has been removed in 0.13

When compiling against Elixir 0.13 you get the following compilation error

== Compilation error on file lib/exzmq/link.ex ==
could not compile dependency exzmq, mix compile failed. You can recompile this dependency with `mix deps.compile exzmq` or update it with `mix deps.update exzmq`
** (CompileError) deps/exzmq/lib/exzmq/link.ex:5: module GenFSM.Behaviour is not loaded and could not be found
    (elixir) /Users/bjornrochel/Coding/Laboratory/zguide/examples/Elixir/zmq/deps/exzmq/lib/exzmq/link.ex:5: Kernel.use/1
    /Users/bjornrochel/Coding/Laboratory/zguide/examples/Elixir/zmq/deps/exzmq/lib/exzmq/link.ex:5: Exzmq.Link (module)

The Elixir maintainers apparently weren't happy with the GenFSM wrapper and removed it :-/

Can't get hello world example to work

Hey there,

this might potentially be a noob question, but I've got trouble getting the simplest 'Hello World' example two work.

I've started to read the ZMQ book and wanted to port the examples over to elixir. The code I'm talking about is located here https://github.com/BjRo/zguide/commit/fdcf59738cfa86afd674ff72ee890893a41cf01a

The server seems to start correctly. However when I try to connect a client from a different shell I get this:

* Generic server <0.60.0> terminating
** Last message in was {connect,tcp,{127,0,0,1},5555,[]}
** When Server state == {'Elixir.Exzmq.Socket',<0.2.0>,
                            {'Elixir.Exzmq.Socket.Fsm.FsmState',
                                'Elixir.Exzmq.Socket.Req',idle,
                                {'Elixir.Exzmq.Socket.Req.State',none}},
                            <<>>,passive,[],none,[],none,[],[],[],[]}
** Reason for termination ==
** {noproc,{gen_server,call,
                       ['Elixir.Exzmq.Link.Sup',{start_child,[]},infinity]}}
** exit {{:noproc, {:gen_server, :call, [Exzmq.Link.Sup, {:start_child, []}, :infinity]}}, {:gen_server, :call, [#PID<0.60.0>, {:connect, :tcp, {127, 0, 0, 1}, 5555, []}]}}
    (stdlib) gen_server.erl:180: :gen_server.call/2
    (zmq) lib/hwclient.ex:5: Zmq.HWclient.run/0
    (stdlib) erl_eval.erl:655: :erl_eval.do_apply/6
    (elixir) src/elixir.erl:140: :elixir.eval_forms/4
    (elixir) lib/code.ex:130: Code.do_eval_string/3
    (elixir) lib/enum.ex:517: Enum."-each/2-lists^foreach/1-0-"/2
    (elixir) lib/enum.ex:517: Enum.each/2
    (mix) lib/mix/tasks/run.ex:53: Mix.Tasks.Run.run/1

It looks like a missed pattern match in connect. Is there something obvious I'm doing wrong? Is it the way I start things via mix run -e "Zmq.HWclient.run"?

what about :queue instead of list

  defstruct socket: nil,
            address: nil,
            acceptor: nil,
            type: nil, # :client or :server
            clients: [], # list of client connections, if socket is of type server
            state: :greeting,
            messages: :queue.new()

Can you make it Elixir 0.15.1 compatible?

I get the error message:

Erlang/OTP 17 [erts-6.1] [source-d2a4c20] [64-bit] [smp:8:8] [async-threads:10] [hipe] [kernel-poll:false]

==> gen_listener_tcp (compile)
Compiled src/gen_listener_tcp.erl

== Compilation error on file lib/exzmq/socket/dealer.ex ==
** (CompileError) lib/exzmq/socket/dealer.ex:6: undefined function defrecord/2
(stdlib) lists.erl:1352: :lists.mapfoldl/3
(elixir) src/elixir_exp.erl:49: :elixir_exp.expand/2
(elixir) src/elixir.erl:206: :elixir.quoted_to_erl/3
(stdlib) erl_eval.erl:657: :erl_eval.do_apply/6
(elixir) src/elixir.erl:175: :elixir.erl_eval/3

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.