Why do we expect \r\n ? why not \0 ?

2011/3/17 <l...@xharbour.com.br>

> Hi
>
> does your server send \r\n with hello?
>
> i read byte by byte until i found an \r\n
>
> Regards
> Luiz
>
> > Hello,
> >
> > In my programm, client send "HELLO" message to server.
> >
> > 1)
> >
> -----------------------------------------------------------------------------------
> > SSL_write is encapsulated in MY_send( ) function like this :
> >
> > MY_send(MY_cn sd, const char* data, size_t len) {
> >        ret = SSL_write(socki->ssl, data, len);
> > }
> >
> > and MY_send is encapsuled in MYsend like this :
> >
> > int MYApi::MYsend(SIP_cn sd, const std::string& data)
> > {
> >   return MY_send(sd, data.data(), data.size());
> >
> > }
> >
> > in python code, I call :
> >
> > api.MYsend(sock, "HELLO")
> >
> > 2)
> >
> ---------------------------------------------------------------------------------------
> > SSL_read is encapsulated in MY_recv( ) function like this :
> >
> > MY_recv(MY_cn sd, char* buf,  size_t* len, unsigned int flags, unsigned
> > int
> > timeout) {
> >          SSL_read(socki->ssl, buf, *len);
> > }
> >
> > and MY_recv is encapsuled in MYrecv like this :
> >
> > int MYApi::MYrecv(MY_cn sd, const std::string& data)
> > {
> >
> >   strresult *r = new strresult;
> >   const size_t L=8*1024;
> >   size_t  len = L;
> >   char buf[L];
> >
> >   r->first = MY_recv(sd, buf, &len, flags, timeout);
> >   if (!r->first)
> >     r->second.assign(buf, len);
> >   return r;
> > }
> >
> > in python code, I call
> > err,data = api.MYrecv(cn, 0, 0)
> >
> >
> > The problem :
> >
> > when I print data, I have got :
> > HELLO��y 0�y
> > 0�y ��y
> >  i`�   0�y
> > ���   ���L���L��-M
> > etc...
> > instead of
> > HELLO.
> >
> > in MYrecv, when I make L = 5, it works
> >
> > what should I do to read just the right size so that when I print I get
> > HELLO, GOODBYE, etc ... and not HELLO��y 0�y ,
> > GOODBYE��y 0�y  etc ...
> > thanks for your help
> >
>
>
> ______________________________________________________________________
> OpenSSL Project                                 http://www.openssl.org
> User Support Mailing List                    openssl-users@openssl.org
> Automated List Manager                           majord...@openssl.org
>

Reply via email to