Bas Wijnen wrote:

Giuseppe Scrivano wrote:

server_socket = socket (PF_INET, SOCK_STREAM, 0);

Check if the call succeeded (server_socket >= 0)

/* address family. */
sock_in.sin_family = PF_INET;
/* port used. */
sock_in.sin_port = htons (8080);
sock_in.sin_addr.s_addr = INADDR_ANY;
err = bind (server_socket, (struct sockaddr *) &sock_in, sizeof (struct sockaddr_in));

Check if the call succeeded (err != -1)


for(;;) { err = listen (server_socket, backlog); addrlen = sizeof (struct sockaddr); socklen_t ddrlen=0; int datatoread; do { datatoread = dataToRead(server_socket); sleep(1);

I don't understand why you need this with a nonzero timeout in select()...


printf("datatoread: %i\n",datatoread);
}
while(!datatoread);
asock = accept (server_socket, (struct sockaddr *) &asock_in, &ddrlen);


    err = send (asock, &send_buff[0], strlen (send_buff), 0);
    if(err != strlen (send_buff))
      printf("Error sending to socket\n");

It is not an error for err to be < strlen (send_buff), as long as it is > 0. == 0 is in many cases not an error either, I think.


My guess is your problem comes from socket() or bind() failing. Check their return value, and errno.

Thanks,
Bas

Hi,
I checked for errors, the socket is created and binded correctly. I also forgot to say that increasing the timeout the select works well, but using a short timeout like in the example, it doesn't report any data.


Regards,
Giuseppe



_______________________________________________
Bug-hurd mailing list
[EMAIL PROTECTED]
http://lists.gnu.org/mailman/listinfo/bug-hurd

Reply via email to