[Serdev] TCP problems

Andrei Pelinescu-Onciul andrei at iptel.org
Thu Jan 11 19:58:14 UTC 2007


On Jan 09, 2007 at 12:44, Katty Xiong <cyyxiong at yahoo.com> wrote:
> 
> Andrei,
> 
> Thanks for your explanation. Could you also explain
> how SER decides whether a SIP message is partial or
> whole? Does it need a special character to seperate
> two SIP messages?

No. Reading a sip message sent over tcp involves the following steps:

0. find the packet start (ignore empty lines)
1. Read until end of headers is found (double CR LF)
2. Search among the headers for the Content-Length and take its value
 (if there is no Content-Length => error, invalid sip message)
3. Read content length bytes (the message body)
4. process sip message (now we have the complete message)
goto 0

Note that 1 & 2 are combined into only 1 step in ser.

> 
> I couldn't quite understand the code for handling tcp
> message. Is the following lines in the function
> tcp_read_req() used to decide if a SIP message is
> complete?
> if ((con->state==S_CONN_EOF) && (req->complete==0)) {
> ...
> }

No, it's the if (req->complete) line  (a few lines below).


Andrei


More information about the Serdev mailing list