Hi
I would like to implement a TCP Server/client using NDK, can anyone post on
example or an ndk project.
Another Question
i implemented an TCP server but when the client connect gethostbyaddr
return NULL any idea
See below the code


childfd = accept(parentfd, (struct sockaddr *) &clientaddr, &clientlen);
 if (childfd < 0)
  printf("ERROR on accept");
/*
         * gethostbyaddr: determine who sent the message
         */
hostp = gethostbyaddr((const char *)&clientaddr.sin_addr.s_addr,
  sizeof(clientaddr.sin_addr.s_addr), AF_INET);
if (hostp == NULL) {
  printf("ERROR on gethostbyaddr\n");
  return 0;

}

    printf("Test1\n");
 hostaddrp = inet_ntoa(clientaddr.sin_addr);
if (hostaddrp == NULL)
  printf("ERROR on inet_ntoa\n");

printf("server established connection with %s (%s)\n",
   hostp->h_name, hostaddrp);

/*
         * read: read input string from the client
         */
bzero(buf, BUFSIZE);
 n = read(childfd, buf, BUFSIZE);
if (n < 0)
  printf("ERROR reading from socket");

printf("server received %d bytes: %s", n, buf);

/*
         * write: echo the input string back to the client
         */
n = write(childfd, buf, strlen(buf));
if (n < 0)
  printf("ERROR writing to socket");

-- 
-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
"Android Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to