<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:st1="urn:schemas-microsoft-com:office:smarttags" xmlns="http://www.w3.org/TR/REC-html40">

<head>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=us-ascii">
<meta name=Generator content="Microsoft Word 11 (filtered medium)">
<!--[if !mso]>
<style>
v\:* {behavior:url(#default#VML);}
o\:* {behavior:url(#default#VML);}
w\:* {behavior:url(#default#VML);}
.shape {behavior:url(#default#VML);}
</style>
<![endif]--><o:SmartTagType
 namespaceuri="urn:schemas-microsoft-com:office:smarttags" name="PersonName"/>
<!--[if !mso]>
<style>
st1\:*{behavior:url(#default#ieooui) }
</style>
<![endif]-->
<style>
<!--
 /* Font Definitions */
 @font-face
        {font-family:Tahoma;
        panose-1:2 11 6 4 3 5 4 4 2 4;}
 /* Style Definitions */
 p.MsoNormal, li.MsoNormal, div.MsoNormal
        {margin:0in;
        margin-bottom:.0001pt;
        font-size:12.0pt;
        font-family:"Times New Roman";}
a:link, span.MsoHyperlink
        {color:blue;
        text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
        {color:purple;
        text-decoration:underline;}
span.EmailStyle17
        {mso-style-type:personal-reply;
        font-family:Arial;
        color:navy;}
@page Section1
        {size:8.5in 11.0in;
        margin:1.0in 1.25in 1.0in 1.25in;}
div.Section1
        {page:Section1;}
-->
</style>

</head>

<body lang=EN-US link=blue vlink=purple>

<div class=Section1>

<p class=MsoNormal><font size=2 color=navy face=Arial><span style='font-size:
10.0pt;font-family:Arial;color:navy'>I just had a thought. Is this something
that I should post to the Asterisk-Dev list? I didn&#8217;t want to cross post,
but I&#8217;m not sure to which list I should have originally posted it. <o:p></o:p></span></font></p>

<p class=MsoNormal><font size=2 color=navy face=Arial><span style='font-size:
10.0pt;font-family:Arial;color:navy'><o:p>&nbsp;</o:p></span></font></p>

<p class=MsoNormal><font size=2 color=navy face=Arial><span style='font-size:
10.0pt;font-family:Arial;color:navy'>Thanks,<o:p></o:p></span></font></p>

<p class=MsoNormal><font size=2 color=navy face=Arial><span style='font-size:
10.0pt;font-family:Arial;color:navy'><br>
<br>
Joshua<o:p></o:p></span></font></p>

<p class=MsoNormal><font size=2 color=navy face=Arial><span style='font-size:
10.0pt;font-family:Arial;color:navy'><o:p>&nbsp;</o:p></span></font></p>

<div>

<div class=MsoNormal align=center style='text-align:center'><font size=3
face="Times New Roman"><span style='font-size:12.0pt'>

<hr size=2 width="100%" align=center tabindex=-1>

</span></font></div>

<p class=MsoNormal><b><font size=2 face=Tahoma><span style='font-size:10.0pt;
font-family:Tahoma;font-weight:bold'>From:</span></font></b><font size=2
face=Tahoma><span style='font-size:10.0pt;font-family:Tahoma'>
asterisk-users-bounces@lists.digium.com
[mailto:asterisk-users-bounces@lists.digium.com] <b><span style='font-weight:
bold'>On Behalf Of </span></b><st1:PersonName w:st="on">Tressler, Joshua A</st1:PersonName><br>
<b><span style='font-weight:bold'>Sent:</span></b> Friday, September 30, 2005
11:52 AM<br>
<b><span style='font-weight:bold'>To:</span></b>
asterisk-users@lists.digium.com<br>
<b><span style='font-weight:bold'>Subject:</span></b> [Asterisk-Users] C
Manager Interface Client</span></font><o:p></o:p></p>

</div>

<p class=MsoNormal><font size=3 face="Times New Roman"><span style='font-size:
12.0pt'><o:p>&nbsp;</o:p></span></font></p>

<div>

<p class=MsoNormal><font size=2 color=black face=Arial><span style='font-size:
10.0pt;font-family:Arial;color:black'>List:</span></font><o:p></o:p></p>

</div>

<div>

<p class=MsoNormal><font size=3 face="Times New Roman"><span style='font-size:
12.0pt'>&nbsp;<o:p></o:p></span></font></p>

</div>

<div>

<p class=MsoNormal><font size=2 color=black face=Arial><span style='font-size:
10.0pt;font-family:Arial;color:black'>This is my first manager client that I've
written so please bear with me:</span></font><o:p></o:p></p>

</div>

<div>

<p class=MsoNormal><font size=3 face="Times New Roman"><span style='font-size:
12.0pt'>&nbsp;<o:p></o:p></span></font></p>

</div>

<div>

<p class=MsoNormal><font size=2 face=Arial><span style='font-size:10.0pt;
font-family:Arial'>I am trying to write a C manager interface client to
interface with our CRM software. I am having an issue while reading the data
from the manager interface.</span></font><o:p></o:p></p>

</div>

<div>

<p class=MsoNormal><font size=3 face="Times New Roman"><span style='font-size:
12.0pt'>&nbsp;<o:p></o:p></span></font></p>

</div>

<div>

<p class=MsoNormal><font size=2 color=black face=Arial><span style='font-size:
10.0pt;font-family:Arial;color:black'>I am writing this in C and I have the
following code:</span></font><o:p></o:p></p>

</div>

<div>

<p class=MsoNormal><font size=2 color=black face=Arial><span style='font-size:
10.0pt;font-family:Arial;color:black'>while(1)<br>
{<br>
&nbsp;bzero(buffer,sizeof(buffer));<br>
&nbsp;readCode = read(socketHandle,buffer,sizeof(buffer));</span></font><o:p></o:p></p>

</div>

<div>

<p class=MsoNormal><font size=2 color=black face=Arial><span style='font-size:
10.0pt;font-family:Arial;color:black'>&nbsp;if(readCode &lt; 0)<br>
&nbsp;{<br>
&nbsp;&nbsp;printf(&quot;ERROR READING FROM SOCKET\n&quot;);<br>
&nbsp;&nbsp;exit(0);<br>
&nbsp;}</span></font><o:p></o:p></p>

</div>

<div>

<p class=MsoNormal><font size=2 color=black face=Arial><span style='font-size:
10.0pt;font-family:Arial;color:black'>&nbsp;printf(&quot;%s&quot;,buffer);<br>
}</span></font><o:p></o:p></p>

</div>

<div>

<p class=MsoNormal><font size=2 color=black face=Arial><span style='font-size:
10.0pt;font-family:Arial;color:black'><br>
This prints out everything just as connecting to the telnet session would print
it out (I do the logging in elsewhere, that isn't the problem here)<o:p></o:p></span></font></p>

</div>

<div>

<p class=MsoNormal><font size=2 color=black face=Arial><span style='font-size:
10.0pt;font-family:Arial;color:black'><br>
This code will read until * has nothing else for me to read from it then print
it all out and wait for some more stuff.&nbsp; Since * seems to print out on
5038 in &quot;blocks&quot; of text read(...) will never cut off in the middle
of a block.<o:p></o:p></span></font></p>

</div>

<div>

<p class=MsoNormal><font size=2 color=black face=Arial><span style='font-size:
10.0pt;font-family:Arial;color:black'>However, on one instance, and this is the
only one we can reproduce the results on, * puts out Event: ****** then stops,
Privilege: ********, then stops and then prints out the rest.&nbsp; This really
screws up my parsing as i normally parse using a tokenizer on \r\n\r\n and pass
each block off to a parsing method.&nbsp; I found this problem using the
following code:<o:p></o:p></span></font></p>

</div>

<div>

<p class=MsoNormal><font size=2 color=black face=Arial><span style='font-size:
10.0pt;font-family:Arial;color:black'>while(1)<br>
{<br>
&nbsp;bzero(buffer,sizeof(buffer));<br>
&nbsp;readCode = read(socketHandle,buffer,sizeof(buffer));<o:p></o:p></span></font></p>

</div>

<div>

<p class=MsoNormal><font size=2 color=black face=Arial><span style='font-size:
10.0pt;font-family:Arial;color:black'>&nbsp;if(readCode &lt; 0)<br>
&nbsp;{<br>
&nbsp;&nbsp;printf(&quot;ERROR READING FROM SOCKET\n&quot;);<br>
&nbsp;&nbsp;exit(0);<br>
&nbsp;}<o:p></o:p></span></font></p>

</div>

<div>

<p class=MsoNormal><font size=2 color=black face=Arial><span style='font-size:
10.0pt;font-family:Arial;color:black'>&nbsp;printf(&quot;%s\n&quot;,buffer);&nbsp;
////////This is the main difference \n<br>
}<o:p></o:p></span></font></p>

</div>

<div>

<p class=MsoNormal><font size=2 color=black face=Arial><span style='font-size:
10.0pt;font-family:Arial;color:black'>In this case I get output as follows:<o:p></o:p></span></font></p>

</div>

<div>

<p class=MsoNormal><font size=2 color=black face=Arial><span style='font-size:
10.0pt;font-family:Arial;color:black'>...<br>
...<br>
.<br>
.<o:p></o:p></span></font></p>

</div>

<div>

<p class=MsoNormal><font size=2 color=black face=Arial><span style='font-size:
10.0pt;font-family:Arial;color:black'>Event: Hangup<o:p></o:p></span></font></p>

</div>

<div>

<p class=MsoNormal><font size=2 color=black face=Arial><span style='font-size:
10.0pt;font-family:Arial;color:black'>&nbsp;<o:p></o:p></span></font></p>

</div>

<div>

<p class=MsoNormal><font size=2 color=black face=Arial><span style='font-size:
10.0pt;font-family:Arial;color:black'>Privilege: call,all<o:p></o:p></span></font></p>

</div>

<div>

<p class=MsoNormal><font size=2 color=black face=Arial><span style='font-size:
10.0pt;font-family:Arial;color:black'>&nbsp;<o:p></o:p></span></font></p>

</div>

<div>

<p class=MsoNormal><font size=2 color=black face=Arial><span style='font-size:
10.0pt;font-family:Arial;color:black'>Channel: SIP/1542200-543f<br>
Uniqueid: 1128041150.26<br>
Cause: 0<br>
Cause-txt: Unknown<o:p></o:p></span></font></p>

</div>

<div>

<p class=MsoNormal><font size=2 color=black face=Arial><span style='font-size:
10.0pt;font-family:Arial;color:black'>...<br>
...<br>
.<br>
.<o:p></o:p></span></font></p>

</div>

<div>

<p class=MsoNormal><font size=2 color=black face=Arial><span style='font-size:
10.0pt;font-family:Arial;color:black'>In this case &quot;Event: Hangup&quot;,
&quot;Privilege: call, all&quot;, and the rest all get passed off to my
parser.&nbsp; Obviously a problem.<o:p></o:p></span></font></p>

</div>

<div>

<p class=MsoNormal><font size=2 color=black face=Arial><span style='font-size:
10.0pt;font-family:Arial;color:black'><br>
Is * spitting this data out to me in three seperate chunks or is my socket not
blocking correctly?<o:p></o:p></span></font></p>

</div>

<div>

<p class=MsoNormal><font size=2 color=black face=Arial><span style='font-size:
10.0pt;font-family:Arial;color:black'><br>
Any suggestions as to why this would happen?<o:p></o:p></span></font></p>

</div>

<div>

<p class=MsoNormal><font size=2 color=black face=Arial><span style='font-size:
10.0pt;font-family:Arial;color:black'>&nbsp;<o:p></o:p></span></font></p>

</div>

<div>

<p class=MsoNormal><font size=2 color=black face=Arial><span style='font-size:
10.0pt;font-family:Arial;color:black'>TIA,<o:p></o:p></span></font></p>

</div>

<div>

<p class=MsoNormal><font size=2 color=black face=Arial><span style='font-size:
10.0pt;font-family:Arial;color:black'>&nbsp;<o:p></o:p></span></font></p>

</div>

<div>

<p class=MsoNormal><font size=2 color=black face=Arial><span style='font-size:
10.0pt;font-family:Arial;color:black'>Joshua</span></font><o:p></o:p></p>

</div>

</div>

</body>

</html>