\doxysection{example\+\_\+tcp\+\_\+echo\+\_\+server.\+c}
\hypertarget{example__tcp__echo__server_8c_source}{}\label{example__tcp__echo__server_8c_source}\index{example\_tcp\_echo\_server.c@{example\_tcp\_echo\_server.c}}

\begin{DoxyCode}{0}
\DoxyCodeLine{\Hypertarget{example__tcp__echo__server_8c_source_l00001}00001\ \textcolor{comment}{/*}}
\DoxyCodeLine{\Hypertarget{example__tcp__echo__server_8c_source_l00002}00002\ \textcolor{comment}{\ *\ \ Copyright\ (C)\ 2012\ Steve\ Harris,\ Stephen\ Sinclair}}
\DoxyCodeLine{\Hypertarget{example__tcp__echo__server_8c_source_l00003}00003\ \textcolor{comment}{\ *}}
\DoxyCodeLine{\Hypertarget{example__tcp__echo__server_8c_source_l00004}00004\ \textcolor{comment}{\ *\ \ This\ program\ is\ free\ software;\ you\ can\ redistribute\ it\ and/or\ modify}}
\DoxyCodeLine{\Hypertarget{example__tcp__echo__server_8c_source_l00005}00005\ \textcolor{comment}{\ *\ \ it\ under\ the\ terms\ of\ the\ GNU\ Lesser\ General\ Public\ License\ as}}
\DoxyCodeLine{\Hypertarget{example__tcp__echo__server_8c_source_l00006}00006\ \textcolor{comment}{\ *\ \ published\ by\ the\ Free\ Software\ Foundation;\ either\ version\ 2.1\ of\ the}}
\DoxyCodeLine{\Hypertarget{example__tcp__echo__server_8c_source_l00007}00007\ \textcolor{comment}{\ *\ \ License,\ or\ (at\ your\ option)\ any\ later\ version.}}
\DoxyCodeLine{\Hypertarget{example__tcp__echo__server_8c_source_l00008}00008\ \textcolor{comment}{\ *}}
\DoxyCodeLine{\Hypertarget{example__tcp__echo__server_8c_source_l00009}00009\ \textcolor{comment}{\ *\ \ This\ program\ is\ distributed\ in\ the\ hope\ that\ it\ will\ be\ useful,}}
\DoxyCodeLine{\Hypertarget{example__tcp__echo__server_8c_source_l00010}00010\ \textcolor{comment}{\ *\ \ but\ WITHOUT\ ANY\ WARRANTY;\ without\ even\ the\ implied\ warranty\ of}}
\DoxyCodeLine{\Hypertarget{example__tcp__echo__server_8c_source_l00011}00011\ \textcolor{comment}{\ *\ \ MERCHANTABILITY\ or\ FITNESS\ FOR\ A\ PARTICULAR\ PURPOSE.\ \ See\ the}}
\DoxyCodeLine{\Hypertarget{example__tcp__echo__server_8c_source_l00012}00012\ \textcolor{comment}{\ *\ \ GNU\ Lesser\ General\ Public\ License\ for\ more\ details.}}
\DoxyCodeLine{\Hypertarget{example__tcp__echo__server_8c_source_l00013}00013\ \textcolor{comment}{\ *}}
\DoxyCodeLine{\Hypertarget{example__tcp__echo__server_8c_source_l00014}00014\ \textcolor{comment}{\ *\ \ \$Id\$}}
\DoxyCodeLine{\Hypertarget{example__tcp__echo__server_8c_source_l00015}00015\ \textcolor{comment}{\ */}}
\DoxyCodeLine{\Hypertarget{example__tcp__echo__server_8c_source_l00016}00016\ }
\DoxyCodeLine{\Hypertarget{example__tcp__echo__server_8c_source_l00017}00017\ \textcolor{comment}{/*\ Run\ this\ program\ in\ one\ terminal\ with\ no\ arguments,}}
\DoxyCodeLine{\Hypertarget{example__tcp__echo__server_8c_source_l00018}00018\ \textcolor{comment}{\ *\ \ \ \$\ ./example\_tcp\_echo\_server}}
\DoxyCodeLine{\Hypertarget{example__tcp__echo__server_8c_source_l00019}00019\ \textcolor{comment}{\ *\ and\ in\ another\ terminal\ with\ argument\ 1,}}
\DoxyCodeLine{\Hypertarget{example__tcp__echo__server_8c_source_l00020}00020\ \textcolor{comment}{\ *\ \ \ \$\ ./example\_tcp\_echo\_server\ 1}}
\DoxyCodeLine{\Hypertarget{example__tcp__echo__server_8c_source_l00021}00021\ \textcolor{comment}{\ *\ Now\ watch\ the\ /test\ message\ ping\ back\ and\ forth\ a\ few\ times!}}
\DoxyCodeLine{\Hypertarget{example__tcp__echo__server_8c_source_l00022}00022\ \textcolor{comment}{\ */}}
\DoxyCodeLine{\Hypertarget{example__tcp__echo__server_8c_source_l00023}00023\ }
\DoxyCodeLine{\Hypertarget{example__tcp__echo__server_8c_source_l00024}00024\ \textcolor{preprocessor}{\#include\ <stdio.h>}}
\DoxyCodeLine{\Hypertarget{example__tcp__echo__server_8c_source_l00025}00025\ \textcolor{preprocessor}{\#include\ <stdlib.h>}}
\DoxyCodeLine{\Hypertarget{example__tcp__echo__server_8c_source_l00026}00026\ \textcolor{preprocessor}{\#ifndef\ WIN32}}
\DoxyCodeLine{\Hypertarget{example__tcp__echo__server_8c_source_l00027}00027\ \textcolor{preprocessor}{\#include\ <unistd.h>}}
\DoxyCodeLine{\Hypertarget{example__tcp__echo__server_8c_source_l00028}00028\ \textcolor{preprocessor}{\#include\ <sys/time.h>}}
\DoxyCodeLine{\Hypertarget{example__tcp__echo__server_8c_source_l00029}00029\ \textcolor{preprocessor}{\#endif}}
\DoxyCodeLine{\Hypertarget{example__tcp__echo__server_8c_source_l00030}00030\ \textcolor{preprocessor}{\#include\ <signal.h>}}
\DoxyCodeLine{\Hypertarget{example__tcp__echo__server_8c_source_l00031}00031\ \textcolor{preprocessor}{\#include\ "{}\doxymbox{\hyperlink{lo_8h}{lo/lo.h}}"{}}}
\DoxyCodeLine{\Hypertarget{example__tcp__echo__server_8c_source_l00032}00032\ }
\DoxyCodeLine{\Hypertarget{example__tcp__echo__server_8c_source_l00033}00033\ \textcolor{keywordtype}{int}\ done\ =\ 0;}
\DoxyCodeLine{\Hypertarget{example__tcp__echo__server_8c_source_l00034}00034\ \textcolor{keywordtype}{int}\ count\ =\ 0;}
\DoxyCodeLine{\Hypertarget{example__tcp__echo__server_8c_source_l00035}00035\ }
\DoxyCodeLine{\Hypertarget{example__tcp__echo__server_8c_source_l00036}00036\ \textcolor{keywordtype}{void}\ error(\textcolor{keywordtype}{int}\ num,\ \textcolor{keyword}{const}\ \textcolor{keywordtype}{char}\ *m,\ \textcolor{keyword}{const}\ \textcolor{keywordtype}{char}\ *path);}
\DoxyCodeLine{\Hypertarget{example__tcp__echo__server_8c_source_l00037}00037\ }
\DoxyCodeLine{\Hypertarget{example__tcp__echo__server_8c_source_l00038}00038\ \textcolor{keywordtype}{int}\ echo\_handler(\textcolor{keyword}{const}\ \textcolor{keywordtype}{char}\ *path,\ \textcolor{keyword}{const}\ \textcolor{keywordtype}{char}\ *types,\ \doxymbox{\hyperlink{unionlo__arg}{lo\_arg}}\ **\ argv,}
\DoxyCodeLine{\Hypertarget{example__tcp__echo__server_8c_source_l00039}00039\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \textcolor{keywordtype}{int}\ argc,\ \doxymbox{\hyperlink{lo__types_8h_a50be181dde1a8d313dbc7e48d4032210}{lo\_message}}\ data,\ \textcolor{keywordtype}{void}\ *user\_data);}
\DoxyCodeLine{\Hypertarget{example__tcp__echo__server_8c_source_l00040}00040\ }
\DoxyCodeLine{\Hypertarget{example__tcp__echo__server_8c_source_l00041}00041\ \textcolor{keywordtype}{int}\ quit\_handler(\textcolor{keyword}{const}\ \textcolor{keywordtype}{char}\ *path,\ \textcolor{keyword}{const}\ \textcolor{keywordtype}{char}\ *types,\ \doxymbox{\hyperlink{unionlo__arg}{lo\_arg}}\ **\ argv,}
\DoxyCodeLine{\Hypertarget{example__tcp__echo__server_8c_source_l00042}00042\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \textcolor{keywordtype}{int}\ argc,\ \doxymbox{\hyperlink{lo__types_8h_a50be181dde1a8d313dbc7e48d4032210}{lo\_message}}\ data,\ \textcolor{keywordtype}{void}\ *user\_data);}
\DoxyCodeLine{\Hypertarget{example__tcp__echo__server_8c_source_l00043}00043\ }
\DoxyCodeLine{\Hypertarget{example__tcp__echo__server_8c_source_l00044}00044\ \textcolor{keywordtype}{void}\ ctrlc(\textcolor{keywordtype}{int}\ sig)}
\DoxyCodeLine{\Hypertarget{example__tcp__echo__server_8c_source_l00045}00045\ \{}
\DoxyCodeLine{\Hypertarget{example__tcp__echo__server_8c_source_l00046}00046\ \ \ \ \ done\ =\ 1;}
\DoxyCodeLine{\Hypertarget{example__tcp__echo__server_8c_source_l00047}00047\ \}}
\DoxyCodeLine{\Hypertarget{example__tcp__echo__server_8c_source_l00048}00048\ }
\DoxyCodeLine{\Hypertarget{example__tcp__echo__server_8c_source_l00049}00049\ \textcolor{keywordtype}{int}\ main(\textcolor{keywordtype}{int}\ argc,\ \textcolor{keywordtype}{char}\ *argv[])}
\DoxyCodeLine{\Hypertarget{example__tcp__echo__server_8c_source_l00050}00050\ \{}
\DoxyCodeLine{\Hypertarget{example__tcp__echo__server_8c_source_l00051}00051\ \ \ \ \ \textcolor{keyword}{const}\ \textcolor{keywordtype}{char}\ *port\ =\ \textcolor{stringliteral}{"{}7770"{}};}
\DoxyCodeLine{\Hypertarget{example__tcp__echo__server_8c_source_l00052}00052\ \ \ \ \ \textcolor{keywordtype}{int}\ do\_send\ =\ 0;}
\DoxyCodeLine{\Hypertarget{example__tcp__echo__server_8c_source_l00053}00053\ }
\DoxyCodeLine{\Hypertarget{example__tcp__echo__server_8c_source_l00054}00054\ \ \ \ \ \textcolor{keywordflow}{if}\ (argc\ >\ 1\ \&\&\ argv[1][0]==\textcolor{charliteral}{'1'})\ \{}
\DoxyCodeLine{\Hypertarget{example__tcp__echo__server_8c_source_l00055}00055\ \ \ \ \ \ \ \ \ do\_send\ =\ 1;}
\DoxyCodeLine{\Hypertarget{example__tcp__echo__server_8c_source_l00056}00056\ \ \ \ \ \ \ \ \ port\ =\ \textcolor{stringliteral}{"{}7771"{}};}
\DoxyCodeLine{\Hypertarget{example__tcp__echo__server_8c_source_l00057}00057\ \ \ \ \ \}}
\DoxyCodeLine{\Hypertarget{example__tcp__echo__server_8c_source_l00058}00058\ }
\DoxyCodeLine{\Hypertarget{example__tcp__echo__server_8c_source_l00059}00059\ \ \ \ \ \textcolor{comment}{/*\ start\ a\ new\ server\ on\ port\ 7770\ */}}
\DoxyCodeLine{\Hypertarget{example__tcp__echo__server_8c_source_l00060}00060\ \ \ \ \ \doxymbox{\hyperlink{lo__types_8h_ade4a4a955cce22c288e0b1b756e4b1cb}{lo\_server\_thread}}\ st\ =\ \doxymbox{\hyperlink{lo__serverthread_8h_a6713cedfb0b2c4f066ec8a19366bf095}{lo\_server\_thread\_new\_with\_proto}}(port,\ LO\_TCP,\ error);}
\DoxyCodeLine{\Hypertarget{example__tcp__echo__server_8c_source_l00061}00061\ \ \ \ \ \textcolor{keywordflow}{if}\ (!st)\ \{}
\DoxyCodeLine{\Hypertarget{example__tcp__echo__server_8c_source_l00062}00062\ \ \ \ \ \ \ \ \ printf(\textcolor{stringliteral}{"{}Could\ not\ create\ server\ thread.\(\backslash\)n"{}});}
\DoxyCodeLine{\Hypertarget{example__tcp__echo__server_8c_source_l00063}00063\ \ \ \ \ \ \ \ \ exit(1);}
\DoxyCodeLine{\Hypertarget{example__tcp__echo__server_8c_source_l00064}00064\ \ \ \ \ \}}
\DoxyCodeLine{\Hypertarget{example__tcp__echo__server_8c_source_l00065}00065\ }
\DoxyCodeLine{\Hypertarget{example__tcp__echo__server_8c_source_l00066}00066\ \ \ \ \ \doxymbox{\hyperlink{lo__types_8h_a009a4f26c17bfcc1c31efc45499d09b8}{lo\_server}}\ s\ =\ \doxymbox{\hyperlink{lo__serverthread_8h_ab968d51fa6e0d4bea92e3f84f5556161}{lo\_server\_thread\_get\_server}}(st);}
\DoxyCodeLine{\Hypertarget{example__tcp__echo__server_8c_source_l00067}00067\ }
\DoxyCodeLine{\Hypertarget{example__tcp__echo__server_8c_source_l00068}00068\ \ \ \ \ \textcolor{comment}{/*\ add\ method\ that\ will\ match\ the\ path\ /quit\ with\ no\ args\ */}}
\DoxyCodeLine{\Hypertarget{example__tcp__echo__server_8c_source_l00069}00069\ \ \ \ \ \doxymbox{\hyperlink{lo__serverthread_8h_af500729c76fd5bb4798d350b6307adc1}{lo\_server\_thread\_add\_method}}(st,\ \textcolor{stringliteral}{"{}/quit"{}},\ \textcolor{stringliteral}{"{}"{}},\ quit\_handler,\ NULL);}
\DoxyCodeLine{\Hypertarget{example__tcp__echo__server_8c_source_l00070}00070\ }
\DoxyCodeLine{\Hypertarget{example__tcp__echo__server_8c_source_l00071}00071\ \ \ \ \ \textcolor{comment}{/*\ add\ method\ that\ will\ match\ any\ path\ and\ args\ */}}
\DoxyCodeLine{\Hypertarget{example__tcp__echo__server_8c_source_l00072}00072\ \ \ \ \ \doxymbox{\hyperlink{lo__serverthread_8h_af500729c76fd5bb4798d350b6307adc1}{lo\_server\_thread\_add\_method}}(st,\ NULL,\ NULL,\ echo\_handler,\ s);}
\DoxyCodeLine{\Hypertarget{example__tcp__echo__server_8c_source_l00073}00073\ }
\DoxyCodeLine{\Hypertarget{example__tcp__echo__server_8c_source_l00074}00074\ \ \ \ \ \doxymbox{\hyperlink{lo__serverthread_8h_a4b284c1b96d0354c5de4ff7ba5a44fbc}{lo\_server\_thread\_start}}(st);}
\DoxyCodeLine{\Hypertarget{example__tcp__echo__server_8c_source_l00075}00075\ }
\DoxyCodeLine{\Hypertarget{example__tcp__echo__server_8c_source_l00076}00076\ \ \ \ \ signal(SIGINT,ctrlc);}
\DoxyCodeLine{\Hypertarget{example__tcp__echo__server_8c_source_l00077}00077\ }
\DoxyCodeLine{\Hypertarget{example__tcp__echo__server_8c_source_l00078}00078\ \ \ \ \ printf(\textcolor{stringliteral}{"{}Listening\ on\ TCP\ port\ \%s\(\backslash\)n"{}},\ port);}
\DoxyCodeLine{\Hypertarget{example__tcp__echo__server_8c_source_l00079}00079\ }
\DoxyCodeLine{\Hypertarget{example__tcp__echo__server_8c_source_l00080}00080\ \ \ \ \ \doxymbox{\hyperlink{lo__types_8h_a463f77a169c38213c73c9622821dcd0d}{lo\_address}}\ a\ =\ 0;}
\DoxyCodeLine{\Hypertarget{example__tcp__echo__server_8c_source_l00081}00081\ \ \ \ \ \textcolor{keywordflow}{if}\ (do\_send)\ \{}
\DoxyCodeLine{\Hypertarget{example__tcp__echo__server_8c_source_l00082}00082\ \ \ \ \ \ \ \ \ a\ =\ \doxymbox{\hyperlink{group__liblo_gaceb4b068bc48c2b075e790910cab3075}{lo\_address\_new\_with\_proto}}(LO\_TCP,\ \textcolor{stringliteral}{"{}localhost"{}},\ \textcolor{stringliteral}{"{}7770"{}});}
\DoxyCodeLine{\Hypertarget{example__tcp__echo__server_8c_source_l00083}00083\ \ \ \ \ \ \ \ \ \textcolor{keywordflow}{if}\ (!a)\ \{}
\DoxyCodeLine{\Hypertarget{example__tcp__echo__server_8c_source_l00084}00084\ \ \ \ \ \ \ \ \ \ \ \ \ printf(\textcolor{stringliteral}{"{}Error\ creating\ destination\ address.\(\backslash\)n"{}});}
\DoxyCodeLine{\Hypertarget{example__tcp__echo__server_8c_source_l00085}00085\ \ \ \ \ \ \ \ \ \ \ \ \ exit(1);}
\DoxyCodeLine{\Hypertarget{example__tcp__echo__server_8c_source_l00086}00086\ \ \ \ \ \ \ \ \ \}}
\DoxyCodeLine{\Hypertarget{example__tcp__echo__server_8c_source_l00087}00087\ \ \ \ \ \ \ \ \ \textcolor{keywordtype}{int}\ r\ =\ \doxymbox{\hyperlink{group__liblo_gaa4a314562b09e2fd00749a5d0b4d0955}{lo\_send\_from}}(a,\ s,\ \doxymbox{\hyperlink{group__liblo_gafa8cfc08b763b0c039fb64a73c4c77da}{LO\_TT\_IMMEDIATE}},\ \textcolor{stringliteral}{"{}/test"{}},\ \textcolor{stringliteral}{"{}ifs"{}},}
\DoxyCodeLine{\Hypertarget{example__tcp__echo__server_8c_source_l00088}00088\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ 1,\ 2.0f,\ \textcolor{stringliteral}{"{}3"{}});}
\DoxyCodeLine{\Hypertarget{example__tcp__echo__server_8c_source_l00089}00089\ \ \ \ \ \ \ \ \ \textcolor{keywordflow}{if}\ (r\ <\ 0)}
\DoxyCodeLine{\Hypertarget{example__tcp__echo__server_8c_source_l00090}00090\ \ \ \ \ \ \ \ \ \ \ \ \ printf(\textcolor{stringliteral}{"{}Error\ sending\ initial\ message.\(\backslash\)n"{}});}
\DoxyCodeLine{\Hypertarget{example__tcp__echo__server_8c_source_l00091}00091\ \ \ \ \ \ \ \ \ \textcolor{keywordflow}{if}\ (a)\ \doxymbox{\hyperlink{group__liblo_ga82b9a2d1d30214114eb5298f43aebac5}{lo\_address\_free}}(a);}
\DoxyCodeLine{\Hypertarget{example__tcp__echo__server_8c_source_l00092}00092\ \ \ \ \ \ \ \ \ a\ =\ 0;}
\DoxyCodeLine{\Hypertarget{example__tcp__echo__server_8c_source_l00093}00093\ \ \ \ \ \}}
\DoxyCodeLine{\Hypertarget{example__tcp__echo__server_8c_source_l00094}00094\ }
\DoxyCodeLine{\Hypertarget{example__tcp__echo__server_8c_source_l00095}00095\ \ \ \ \ \textcolor{keywordflow}{while}\ (!done)\ \{}
\DoxyCodeLine{\Hypertarget{example__tcp__echo__server_8c_source_l00096}00096\ \textcolor{preprocessor}{\#ifdef\ WIN32}}
\DoxyCodeLine{\Hypertarget{example__tcp__echo__server_8c_source_l00097}00097\ \ \ \ \ \ \ \ \ Sleep(1);}
\DoxyCodeLine{\Hypertarget{example__tcp__echo__server_8c_source_l00098}00098\ \textcolor{preprocessor}{\#else}}
\DoxyCodeLine{\Hypertarget{example__tcp__echo__server_8c_source_l00099}00099\ \ \ \ \ \ \ \ \ sleep(1);}
\DoxyCodeLine{\Hypertarget{example__tcp__echo__server_8c_source_l00100}00100\ \textcolor{preprocessor}{\#endif}}
\DoxyCodeLine{\Hypertarget{example__tcp__echo__server_8c_source_l00101}00101\ \ \ \ \ \}}
\DoxyCodeLine{\Hypertarget{example__tcp__echo__server_8c_source_l00102}00102\ }
\DoxyCodeLine{\Hypertarget{example__tcp__echo__server_8c_source_l00103}00103\ \ \ \ \ \doxymbox{\hyperlink{lo__serverthread_8h_ad72be3f2a81b9583ad69dd007080c0e5}{lo\_server\_thread\_free}}(st);}
\DoxyCodeLine{\Hypertarget{example__tcp__echo__server_8c_source_l00104}00104\ }
\DoxyCodeLine{\Hypertarget{example__tcp__echo__server_8c_source_l00105}00105\ \ \ \ \ \textcolor{keywordflow}{return}\ 0;}
\DoxyCodeLine{\Hypertarget{example__tcp__echo__server_8c_source_l00106}00106\ \}}
\DoxyCodeLine{\Hypertarget{example__tcp__echo__server_8c_source_l00107}00107\ }
\DoxyCodeLine{\Hypertarget{example__tcp__echo__server_8c_source_l00108}00108\ \textcolor{keywordtype}{void}\ error(\textcolor{keywordtype}{int}\ num,\ \textcolor{keyword}{const}\ \textcolor{keywordtype}{char}\ *msg,\ \textcolor{keyword}{const}\ \textcolor{keywordtype}{char}\ *path)}
\DoxyCodeLine{\Hypertarget{example__tcp__echo__server_8c_source_l00109}00109\ \{}
\DoxyCodeLine{\Hypertarget{example__tcp__echo__server_8c_source_l00110}00110\ \ \ \ \ printf(\textcolor{stringliteral}{"{}liblo\ server\ error\ \%d\ in\ path\ \%s:\ \%s\(\backslash\)n"{}},\ num,\ path,\ msg);}
\DoxyCodeLine{\Hypertarget{example__tcp__echo__server_8c_source_l00111}00111\ \ \ \ \ fflush(stdout);}
\DoxyCodeLine{\Hypertarget{example__tcp__echo__server_8c_source_l00112}00112\ \}}
\DoxyCodeLine{\Hypertarget{example__tcp__echo__server_8c_source_l00113}00113\ }
\DoxyCodeLine{\Hypertarget{example__tcp__echo__server_8c_source_l00114}00114\ \textcolor{comment}{/*\ catch\ any\ incoming\ messages,\ display\ them,\ and\ send\ them}}
\DoxyCodeLine{\Hypertarget{example__tcp__echo__server_8c_source_l00115}00115\ \textcolor{comment}{\ *\ back.\ */}}
\DoxyCodeLine{\Hypertarget{example__tcp__echo__server_8c_source_l00116}00116\ \textcolor{keywordtype}{int}\ echo\_handler(\textcolor{keyword}{const}\ \textcolor{keywordtype}{char}\ *path,\ \textcolor{keyword}{const}\ \textcolor{keywordtype}{char}\ *types,\ \doxymbox{\hyperlink{unionlo__arg}{lo\_arg}}\ **\ argv,}
\DoxyCodeLine{\Hypertarget{example__tcp__echo__server_8c_source_l00117}00117\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \textcolor{keywordtype}{int}\ argc,\ \doxymbox{\hyperlink{lo__types_8h_a50be181dde1a8d313dbc7e48d4032210}{lo\_message}}\ data,\ \textcolor{keywordtype}{void}\ *user\_data)}
\DoxyCodeLine{\Hypertarget{example__tcp__echo__server_8c_source_l00118}00118\ \{}
\DoxyCodeLine{\Hypertarget{example__tcp__echo__server_8c_source_l00119}00119\ \ \ \ \ \textcolor{keywordtype}{int}\ i;}
\DoxyCodeLine{\Hypertarget{example__tcp__echo__server_8c_source_l00120}00120\ \ \ \ \ \doxymbox{\hyperlink{lo__types_8h_a50be181dde1a8d313dbc7e48d4032210}{lo\_message}}\ m\ =\ (\doxymbox{\hyperlink{lo__types_8h_a50be181dde1a8d313dbc7e48d4032210}{lo\_message}})data;}
\DoxyCodeLine{\Hypertarget{example__tcp__echo__server_8c_source_l00121}00121\ \ \ \ \ \doxymbox{\hyperlink{lo__types_8h_a463f77a169c38213c73c9622821dcd0d}{lo\_address}}\ a\ =\ \doxymbox{\hyperlink{group__liblolowlevel_ga1f4e07e4f8b67edc98f4b300412a3dbb}{lo\_message\_get\_source}}(m);}
\DoxyCodeLine{\Hypertarget{example__tcp__echo__server_8c_source_l00122}00122\ \ \ \ \ \doxymbox{\hyperlink{lo__types_8h_a009a4f26c17bfcc1c31efc45499d09b8}{lo\_server}}\ s\ =\ (\doxymbox{\hyperlink{lo__types_8h_a009a4f26c17bfcc1c31efc45499d09b8}{lo\_server}})user\_data;}
\DoxyCodeLine{\Hypertarget{example__tcp__echo__server_8c_source_l00123}00123\ \ \ \ \ \textcolor{keyword}{const}\ \textcolor{keywordtype}{char}\ *host\ =\ \doxymbox{\hyperlink{group__liblolowlevel_ga0a6ba65c3b486c5a9a2f51fc90eb3235}{lo\_address\_get\_hostname}}(a);}
\DoxyCodeLine{\Hypertarget{example__tcp__echo__server_8c_source_l00124}00124\ \ \ \ \ \textcolor{keyword}{const}\ \textcolor{keywordtype}{char}\ *port\ =\ \doxymbox{\hyperlink{group__liblolowlevel_gac3262b6d9adca5ee008a3411a24d1b0c}{lo\_address\_get\_port}}(a);}
\DoxyCodeLine{\Hypertarget{example__tcp__echo__server_8c_source_l00125}00125\ }
\DoxyCodeLine{\Hypertarget{example__tcp__echo__server_8c_source_l00126}00126\ \ \ \ \ count\ ++;}
\DoxyCodeLine{\Hypertarget{example__tcp__echo__server_8c_source_l00127}00127\ }
\DoxyCodeLine{\Hypertarget{example__tcp__echo__server_8c_source_l00128}00128\ \textcolor{preprocessor}{\#ifdef\ WIN32}}
\DoxyCodeLine{\Hypertarget{example__tcp__echo__server_8c_source_l00129}00129\ \ \ \ \ Sleep(1);}
\DoxyCodeLine{\Hypertarget{example__tcp__echo__server_8c_source_l00130}00130\ \textcolor{preprocessor}{\#else}}
\DoxyCodeLine{\Hypertarget{example__tcp__echo__server_8c_source_l00131}00131\ \ \ \ \ sleep(1);}
\DoxyCodeLine{\Hypertarget{example__tcp__echo__server_8c_source_l00132}00132\ \textcolor{preprocessor}{\#endif}}
\DoxyCodeLine{\Hypertarget{example__tcp__echo__server_8c_source_l00133}00133\ }
\DoxyCodeLine{\Hypertarget{example__tcp__echo__server_8c_source_l00134}00134\ \ \ \ \ printf(\textcolor{stringliteral}{"{}path:\ <\%s>\(\backslash\)n"{}},\ path);}
\DoxyCodeLine{\Hypertarget{example__tcp__echo__server_8c_source_l00135}00135\ \ \ \ \ \textcolor{keywordflow}{for}\ (i\ =\ 0;\ i\ <\ argc;\ i++)\ \{}
\DoxyCodeLine{\Hypertarget{example__tcp__echo__server_8c_source_l00136}00136\ \ \ \ \ \ \ \ \ printf(\textcolor{stringliteral}{"{}arg\ \%d\ '\%c'\ "{}},\ i,\ types[i]);}
\DoxyCodeLine{\Hypertarget{example__tcp__echo__server_8c_source_l00137}00137\ \ \ \ \ \ \ \ \ \doxymbox{\hyperlink{group__pp_ga1699678a3a2d4221bb55fa2e05326ef0}{lo\_arg\_pp}}((\doxymbox{\hyperlink{group__liblo_ga11838c576b0197c255ce805fd7434736}{lo\_type}})types[i],\ argv[i]);}
\DoxyCodeLine{\Hypertarget{example__tcp__echo__server_8c_source_l00138}00138\ \ \ \ \ \ \ \ \ printf(\textcolor{stringliteral}{"{}\(\backslash\)n"{}});}
\DoxyCodeLine{\Hypertarget{example__tcp__echo__server_8c_source_l00139}00139\ \ \ \ \ \}}
\DoxyCodeLine{\Hypertarget{example__tcp__echo__server_8c_source_l00140}00140\ }
\DoxyCodeLine{\Hypertarget{example__tcp__echo__server_8c_source_l00141}00141\ \ \ \ \ \textcolor{keywordflow}{if}\ (!a)\ \{}
\DoxyCodeLine{\Hypertarget{example__tcp__echo__server_8c_source_l00142}00142\ \ \ \ \ \ \ \ \ printf(\textcolor{stringliteral}{"{}Couldn't\ get\ message\ source,\ quitting.\(\backslash\)n"{}});}
\DoxyCodeLine{\Hypertarget{example__tcp__echo__server_8c_source_l00143}00143\ \ \ \ \ \ \ \ \ done\ =\ 1;}
\DoxyCodeLine{\Hypertarget{example__tcp__echo__server_8c_source_l00144}00144\ \ \ \ \ \ \ \ \ \textcolor{keywordflow}{return}\ 0;}
\DoxyCodeLine{\Hypertarget{example__tcp__echo__server_8c_source_l00145}00145\ \ \ \ \ \}}
\DoxyCodeLine{\Hypertarget{example__tcp__echo__server_8c_source_l00146}00146\ }
\DoxyCodeLine{\Hypertarget{example__tcp__echo__server_8c_source_l00147}00147\ \ \ \ \ \textcolor{keywordtype}{int}\ r\ =\ \doxymbox{\hyperlink{group__liblolowlevel_ga9d1aa7c1ee1ce60fe0cf7e3f1e5a6822}{lo\_send\_message\_from}}(a,\ s,\ path,\ m);}
\DoxyCodeLine{\Hypertarget{example__tcp__echo__server_8c_source_l00148}00148\ \ \ \ \ \textcolor{keywordflow}{if}\ (r\ <\ 0)}
\DoxyCodeLine{\Hypertarget{example__tcp__echo__server_8c_source_l00149}00149\ \ \ \ \ \ \ \ \ printf(\textcolor{stringliteral}{"{}Error\ sending\ back\ message,\ socket\ may\ have\ closed.\(\backslash\)n"{}});}
\DoxyCodeLine{\Hypertarget{example__tcp__echo__server_8c_source_l00150}00150\ \ \ \ \ \textcolor{keywordflow}{else}}
\DoxyCodeLine{\Hypertarget{example__tcp__echo__server_8c_source_l00151}00151\ \ \ \ \ \ \ \ \ printf(\textcolor{stringliteral}{"{}Sent\ message\ back\ to\ \%s:\%s.\(\backslash\)n"{}},\ host,\ port);}
\DoxyCodeLine{\Hypertarget{example__tcp__echo__server_8c_source_l00152}00152\ \ \ \ \ }
\DoxyCodeLine{\Hypertarget{example__tcp__echo__server_8c_source_l00153}00153\ \ \ \ \ \textcolor{keywordflow}{if}\ (count\ >=\ 3)\ \{}
\DoxyCodeLine{\Hypertarget{example__tcp__echo__server_8c_source_l00154}00154\ \ \ \ \ \ \ \ \ printf(\textcolor{stringliteral}{"{}Got\ enough\ messages,\ quitting.\(\backslash\)n"{}});}
\DoxyCodeLine{\Hypertarget{example__tcp__echo__server_8c_source_l00155}00155\ \ \ \ \ \ \ \ \ done\ =\ 1;}
\DoxyCodeLine{\Hypertarget{example__tcp__echo__server_8c_source_l00156}00156\ \ \ \ \ \}}
\DoxyCodeLine{\Hypertarget{example__tcp__echo__server_8c_source_l00157}00157\ }
\DoxyCodeLine{\Hypertarget{example__tcp__echo__server_8c_source_l00158}00158\ \ \ \ \ \textcolor{keywordflow}{return}\ 0;}
\DoxyCodeLine{\Hypertarget{example__tcp__echo__server_8c_source_l00159}00159\ \}}
\DoxyCodeLine{\Hypertarget{example__tcp__echo__server_8c_source_l00160}00160\ }
\DoxyCodeLine{\Hypertarget{example__tcp__echo__server_8c_source_l00161}00161\ \textcolor{keywordtype}{int}\ quit\_handler(\textcolor{keyword}{const}\ \textcolor{keywordtype}{char}\ *path,\ \textcolor{keyword}{const}\ \textcolor{keywordtype}{char}\ *types,\ \doxymbox{\hyperlink{unionlo__arg}{lo\_arg}}\ **\ argv,}
\DoxyCodeLine{\Hypertarget{example__tcp__echo__server_8c_source_l00162}00162\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \textcolor{keywordtype}{int}\ argc,\ \doxymbox{\hyperlink{lo__types_8h_a50be181dde1a8d313dbc7e48d4032210}{lo\_message}}\ data,\ \textcolor{keywordtype}{void}\ *user\_data)}
\DoxyCodeLine{\Hypertarget{example__tcp__echo__server_8c_source_l00163}00163\ \{}
\DoxyCodeLine{\Hypertarget{example__tcp__echo__server_8c_source_l00164}00164\ \ \ \ \ done\ =\ 1;}
\DoxyCodeLine{\Hypertarget{example__tcp__echo__server_8c_source_l00165}00165\ \ \ \ \ printf(\textcolor{stringliteral}{"{}quitting\(\backslash\)n\(\backslash\)n"{}});}
\DoxyCodeLine{\Hypertarget{example__tcp__echo__server_8c_source_l00166}00166\ \ \ \ \ fflush(stdout);}
\DoxyCodeLine{\Hypertarget{example__tcp__echo__server_8c_source_l00167}00167\ }
\DoxyCodeLine{\Hypertarget{example__tcp__echo__server_8c_source_l00168}00168\ \ \ \ \ \textcolor{keywordflow}{return}\ 0;}
\DoxyCodeLine{\Hypertarget{example__tcp__echo__server_8c_source_l00169}00169\ \}}

\end{DoxyCode}
