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

Reply via email to