-
Install opam
sudo apt install opam
-
Create a switch for OCaml 4.14.0
opam init -y opam sw create 4.14.0 eval $(opam env)
-
Clone the repo
git clone git@github.com:shubhamkumar13/ahrefs-chat-app.git
-
Install the opam packages using the
opam_packages.export
cd /path/to/ahrefs-chat-app opam sw import opam_packages.export
N.B. : If there are errors while importing the packages where related to
conf-gmp
andconf-libev
run the following commandssudo apt install libgmp-dev libev-dev
- Build the app
cd /path/to/ahrefs-chat-app dune build @all
- To start a server
dune exec main
- as soon as you execute the above command
you should see a prompt as shown below
type in the port number that you want, do remember that the port for server and client should be same.
❯ dune exec main Choose which port you want to run your application in {Please make sure that the port selected should be same for server and client, thank you} : =>
- Let's choose
8080
and press enter, this would bring you down to the next option menu as shown below. (If you don't choose anything 8080 is the default port)❯ dune exec main Choose which port you want to run your application in {Please make sure that the port selected should be same for server and client, thank you} : => 8080 Choose which application you want to run : 1. For running a server choose 1 2. For running a client choose 2 =>
- Now if you haven't started a server choosing
option 2 would end up with refusal of connection.
So choose 1, by typing 1.
You will se a prompt :
Waiting for socket connection :
which would change to :Waiting for socket connection : Client connected : 127.0.0.1 Enter message :
- For choosing to run a client choose option 2
This will show the following prompt
now you can send and receive messages from client and server. Fin.
Enter message :