[Tex/LaTex] Why doesn’t \newline work inside lstlisting

line-breakinglistings

I am new to LaTeX and am using a template provided by a friend:

 \subsection{P2P library}
The library is implemented in C-Sharp and provides two basic facilities - maintaining a member list at every instance and the support for receving and multicasting UDP data. 

The public methods it has are 
\begin{lstlisting}
      void setPorts(int recvHere \newline, int sendFrom

Why doesn't ,int sendFrom move to a new line in the PDF output? In fact it just shows up in the PDF output.

Best Answer

As commented by Peter Grill, lstlisting is a verbatim environment, meaning that its contents are printed exactly as they appear in the code. As this also includes linebreaks, you could simply add a linebreak in the code.

\begin{lstlisting}
      void setPorts(int recvHere 
      , int sendFrom
\end{lstlisting}