You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@apr.apache.org by Cristiano Maciel da Silva <cr...@yahoo.com.br> on 2003/08/02 13:30:56 UTC

troubles while connecting thru apr sockets

gentlemen,

i noticed a very interesting behaviour of apr sockets.

when i try to read something just after a connect, the read operation returns
"end of file".

but, if i do connect, write anything to the socket, and then read it, it works
fine and i receive the expected output.

is that a apr buggy?

below i show you such the mistaked code section:

> > >   {
> > >     apr_byte_t      dummy_buffer[1000];
> > >     apr_size_t      size;
> > >     apr_socket_t   *sock; // the socket
> > >     apr_sockaddr_t *addr; // the address
> > >
> > >     // just connect to the ssh port and prints the
> > >     // received bytes on the screen
> > >     // 150.164.3.194 is a valid addr here, ok?
> > >     apr_sockaddr_info_get
> > >        (&addr, "150.164.3.194", AF_INET, 22, 0, root_pool);
> > >
> > >     // creates the socket
> > >     apr_socket_create_ex  (&sock, APR_INET, SOCK_STREAM, APR_PROTO_TCP,
> > > root_pool);
> > >
> > >     // connects to the specified addr
> > >     apr_socket_connect    (sock, addr);
> > >
> > >     // reads anything
> > >     apr_socket_recv (sock, dummy_buffer, &size);
> > >
> > >     // encloses the string
> > >     buf[size] = 0;
> > >
> > >     // prints on screen
> > >     printf ("%s\n", dummy_buffer );
> > >   }

well, thanks for your help.

cristiano.

_______________________________________________________________________
Conheça o novo Cadê? - Mais rápido, mais fácil e mais preciso.
Toda a web, 42 milhões de páginas brasileiras e nova busca por imagens!
http://www.cade.com.br

Re: troubles while connecting thru apr sockets

Posted by Jeff Trawick <tr...@attglobal.net>.
Cristiano Maciel da Silva wrote:

> gentlemen,

that may be stretching it a bit...

> when i try to read something just after a connect, the read operation returns
> "end of file".

does it return APR_EOF immediately, or after a delay

> 
> but, if i do connect, write anything to the socket, and then read it, it works
> fine and i receive the expected output.

maybe this behavior is due to the way the peer works?  (i.e., it drops 
the connection if it doesn't receive any data)

by chance have you tried your client code anywhere besides Windows?

do you ever call apr_recv() when apr_connect() is what actually failed?

> is that a apr buggy?

unclear