[Tex/LaTex] Draw curved path inside circle

pathstikz-pgf

How to draw the curved line inside the red circle in this picture :
enter image description here

MWE

\documentclass[tikz]{standalone}
\usepackage[utf8]{inputenc}
\usetikzlibrary{shapes.geometric,arrows,positioning,fit,calc,backgrounds}

\begin{document}
   \begin{tikzpicture}
      \draw (-2,0) circle (.4cm) node[below=.5cm, align=center] {Client};
      \draw[color=red] (0,0) circle (.4cm) node[below=.5cm, text width=1.5cm, color=black, align=center] {Homme du milieu};
      \draw (2,0) circle (.4cm) node[below=.5cm, align=center, text width=1cm] {Serveur web};
      \draw[color=blue] (-2, 0) -- (-.4,0);
      \draw[color=blue] (.4, 0) -- (2,0);

      \draw[-, color=red] (-.4,0) to[out=-30,in=100,looseness=2] (.4,0) ;
   \end{tikzpicture}
\end{document}

How does function the to[out=-30,in=100,looseness=2] work?. I read an answer that suggested using it for making curved paths but I don't know how it works.

Best Answer

I suggest to use named circle nodes. If the red one is called hdm you can use something like

\draw[red,looseness=1.5] (hdm.west) to[out=70,in =110] (hdm.center) to [out=-70,in=-110](hdm.east); 

to get

enter image description here

Code:

\documentclass[tikz,margin=5mm]{standalone}
\begin{document}
   \begin{tikzpicture}[mycircle/.style={draw,circle,minimum size=.8cm}]
      \node[mycircle,label=below:Client](client)at (-2,0){};
      \node[mycircle,red,label={[text width=1.5cm,align=center]below:Homme du milieu}](hdm){};
     \node[mycircle,label=below:Server web](sweb)at (2,0){};
      \draw[color=blue] (client.center) -- (hdm) -- (sweb.center);
      \draw[red,looseness=1.5] (hdm.west) to[out=70,in =110] (hdm.center) to [out=-70,in=-110](hdm.east);
   \end{tikzpicture}
\end{document}

Here is a picture to explain how

\draw[looseness=1.5] (hdm.west) to[out=70,in =110] (hdm.center) to [out=-70,in=-110](hdm.east);

works (looseness=0.5 is green, looseness=1.5 is orange and loosness=2 is blue):

enter image description here

Code:

\documentclass[tikz,margin=5mm]{standalone}
\usetikzlibrary{angles,quotes}
\usepackage{textcomp}
\begin{document}
   \begin{tikzpicture}
      [myangle/.style={draw=red,thick,angle radius=1cm,fill=blue!10,fill opacity=0.5,}]
      \node[draw,circle,minimum size=8cm](hdm){};
      \foreach \l/\c in {0.5/green,1.5/orange,2/blue}
        \draw[thick,dashed,\c,looseness=\l] 
          (hdm.west) to[out=70,in =110] node[below]{\l}(hdm.center) to [out=-70,in=-110](hdm.east);
      \draw[help lines,thick]([xshift=-1cm]hdm.west)--([xshift=1cm]hdm.east)coordinate(H);
      \draw(hdm.west)coordinate[label=below left:hdm.west](A)--+(70:2)coordinate(B)
           (hdm.center)coordinate[label=below left:hdm.center](C)--+(110:2)coordinate(D)--+(-70:2)coordinate(E)
           (hdm.east)coordinate[label=above right:hdm.east](F)--+(-110:2)coordinate(G);
      \pic[myangle,->,"70\textdegree"]{angle=C--A--B};
      \pic[myangle,->,"110\textdegree"]{angle=F--C--D};
      \pic[myangle,<-|,"-70\textdegree"]{angle=E--C--F};
      \pic[myangle,<-,"-110\textdegree"]{angle=G--F--H};
   \end{tikzpicture}
\end{document}