<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"><HTML DIR=ltr><HEAD><META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=iso-8859-1"></HEAD><BODY><DIV><FONT face='Arial' color=#000000 size=2>List:</FONT></DIV>
<DIV><FONT face=Arial color=#000000 size=2></FONT>&nbsp;</DIV>
<DIV><FONT face=Arial color=#000000 size=2>This is my first manager client that 
I've written so please bear with me:</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT>&nbsp;</DIV>
<DIV><FONT face=Arial size=2>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.</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT>&nbsp;</DIV>
<DIV><FONT face=Arial color=#000000 size=2>I am writing this in C and I have the 
following code:</FONT></DIV>
<DIV><FONT face=Arial color=#000000 
size=2>while(1)<BR>{<BR>&nbsp;bzero(buffer,sizeof(buffer));<BR>&nbsp;readCode = 
read(socketHandle,buffer,sizeof(buffer));</FONT></DIV>
<DIV><FONT face=Arial color=#000000 size=2>&nbsp;if(readCode &lt; 
0)<BR>&nbsp;{<BR>&nbsp;&nbsp;printf("ERROR READING FROM 
SOCKET\n");<BR>&nbsp;&nbsp;exit(0);<BR>&nbsp;}</FONT></DIV>
<DIV><FONT face=Arial color=#000000 
size=2>&nbsp;printf("%s",buffer);<BR>}</FONT></DIV><FONT face=Arial 
color=#000000 size=2>
<DIV><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)</DIV>
<DIV><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 "blocks" of text read(...) will never cut off in the middle of a 
block.</DIV>
<DIV>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:</DIV>
<DIV>while(1)<BR>{<BR>&nbsp;bzero(buffer,sizeof(buffer));<BR>&nbsp;readCode = 
read(socketHandle,buffer,sizeof(buffer));</DIV>
<DIV>&nbsp;if(readCode &lt; 0)<BR>&nbsp;{<BR>&nbsp;&nbsp;printf("ERROR READING 
FROM SOCKET\n");<BR>&nbsp;&nbsp;exit(0);<BR>&nbsp;}</DIV>
<DIV>&nbsp;printf("%s\n",buffer);&nbsp; ////////This is the main difference 
\n<BR>}</DIV>
<DIV>In this case I get output as follows:</DIV>
<DIV>...<BR>...<BR>.<BR>.</DIV>
<DIV>Event: Hangup</DIV>
<DIV>&nbsp;</DIV>
<DIV>Privilege: call,all</DIV>
<DIV>&nbsp;</DIV>
<DIV>Channel: SIP/1542200-543f<BR>Uniqueid: 1128041150.26<BR>Cause: 
0<BR>Cause-txt: Unknown</DIV>
<DIV>...<BR>...<BR>.<BR>.</DIV>
<DIV>In this case "Event: Hangup", "Privilege: call, all", and the rest all get 
passed off to my parser.&nbsp; Obviously a problem.</DIV>
<DIV><BR>Is * spitting this data out to me in three seperate chunks or is my 
socket not blocking correctly?</DIV>
<DIV><BR>Any suggestions as to why this would happen?</DIV>
<DIV>&nbsp;</DIV>
<DIV>TIA,</DIV>
<DIV>&nbsp;</DIV>
<DIV>Joshua</FONT></DIV></BODY></HTML>