<!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> </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> </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> </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> bzero(buffer,sizeof(buffer));<BR> readCode =
read(socketHandle,buffer,sizeof(buffer));</FONT></DIV>
<DIV><FONT face=Arial color=#000000 size=2> if(readCode <
0)<BR> {<BR> printf("ERROR READING FROM
SOCKET\n");<BR> exit(0);<BR> }</FONT></DIV>
<DIV><FONT face=Arial color=#000000
size=2> 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. 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. 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. I found this problem using the following code:</DIV>
<DIV>while(1)<BR>{<BR> bzero(buffer,sizeof(buffer));<BR> readCode =
read(socketHandle,buffer,sizeof(buffer));</DIV>
<DIV> if(readCode < 0)<BR> {<BR> printf("ERROR READING
FROM SOCKET\n");<BR> exit(0);<BR> }</DIV>
<DIV> printf("%s\n",buffer); ////////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> </DIV>
<DIV>Privilege: call,all</DIV>
<DIV> </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. 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> </DIV>
<DIV>TIA,</DIV>
<DIV> </DIV>
<DIV>Joshua</FONT></DIV></BODY></HTML>