Skip to content

ohhi-vn/gen_tcp

Repository files navigation

Gen_tcp

First Example

Both Client and Server is run on Elixir service.

Uncomment 2 lines in application.ex:

       %{id: GenTcp.Server, start: {GenTcp.Server, :start_link, [[]]}},
       %{id: GenTcp.Client, start: {GenTcp.Client, :start_link, [[]]}}

Start the server by command: iex -S mix

Run these command:

alias GenTcp.Client
Client.send_to_server("Hello")
Client.close_socket()

Second Example

Client is run on Elixir service, Server is run on Python service.

Comment 2 lines in application.ex:

       %{id: GenTcp.Server, start: {GenTcp.Server, :start_link, [[]]}},
       %{id: GenTcp.Client, start: {GenTcp.Client, :start_link, [[]]}}

Terminal 1:

Start the server by command: iex -S mix

Run these commands to simulate the client-server:

alias GenTcp.ServerInteracPy
ServerInteracPy.start_server()

Terminal 2:

Run these commands:

cd lib/gen_tcp
python3 client_py.py

About

Distributed messages by gen_tcp with Elixir

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published