apr-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dr...@apache.org
Subject cvs commit: apr/network_io/beos sendrecv.c
Date Tue, 20 Mar 2001 13:47:08 GMT
dreid       01/03/20 05:47:07

  Modified:    network_io/beos sendrecv.c
  Log:
  Add the UDP support to BeOS R5.
  
  Revision  Changes    Path
  1.20      +76 -0     apr/network_io/beos/sendrecv.c
  
  Index: sendrecv.c
  ===================================================================
  RCS file: /home/cvs/apr/network_io/beos/sendrecv.c,v
  retrieving revision 1.19
  retrieving revision 1.20
  diff -u -r1.19 -r1.20
  --- sendrecv.c	2001/02/16 04:16:00	1.19
  +++ sendrecv.c	2001/03/20 13:47:00	1.20
  @@ -160,4 +160,80 @@
       return apr_send(sock, vec[0].iov_base, len);
   }
   
  +apr_status_t apr_sendto(apr_socket_t *sock, apr_sockaddr_t *where,
  +                        apr_int32_t flags, const char *buf, apr_size_t *len)
  +{
  +    ssize_t rv;
  +
  +    do {
  +        rv = sendto(sock->socketdes, buf, (*len), flags,
  +                    (const struct sockaddr*)&where->sa,
  +                    where->salen);
  +    } while (rv == -1 && errno == EINTR);
  +
  +    if (rv == -1 && (errno == EAGAIN || errno == EWOULDBLOCK)
  +        && sock->timeout != 0) {
  +        apr_status_t arv = wait_for_io_or_timeout(sock, 0);
  +        if (arv != APR_SUCCESS) {
  +            *len = 0;
  +            return arv;
  +        } else {
  +            do {
  +                rv = sendto(sock->socketdes, buf, (*len), flags,
  +                            (const struct sockaddr*)&where->sa,
  +                            where->salen);
  +            } while (rv == -1 && errno == EINTR);
  +        }
  +    }
  +    if (rv == -1) {
  +        *len = 0;
  +        return errno;
  +    }
  +    *len = rv;
  +    return APR_SUCCESS;
  +}
  +
  +apr_status_t apr_recvfrom(apr_sockaddr_t *from, apr_socket_t *sock,
  +                          apr_int32_t flags, char *buf,
  +                          apr_size_t *len)
  +{
  +    ssize_t rv;
  +
  +    if (from == NULL){
  +        return APR_ENOMEM;
  +        /* Not sure if this is correct.  Maybe we should just allocate
  +           the memory??
  +         */
  +    }
  +
  +    do {
  +        rv = recvfrom(sock->socketdes, buf, (*len), flags,
  +                      (struct sockaddr*)&from->sa, &from->salen);
  +    } while (rv == -1 && errno == EINTR);
  +
  +    if (rv == -1 && (errno == EAGAIN || errno == EWOULDBLOCK) &&
  +        sock->timeout != 0) {
  +        apr_status_t arv = wait_for_io_or_timeout(sock, 1);
  +        if (arv != APR_SUCCESS) {
  +            *len = 0;
  +            return arv;
  +        } else {
  +            do {
  +                rv = recvfrom(sock->socketdes, buf, (*len), flags,
  +                              (struct sockaddr*)&from->sa, &from->salen);
  +                } while (rv == -1 && errno == EINTR);
  +        }
  +    }
  +    if (rv == -1) {
  +        (*len) = 0;
  +        return errno;
  +    }
  +
  +    (*len) = rv;
  +    if (rv == 0)
  +        return APR_EOF;
  +
  +    return APR_SUCCESS;
  +}
  +
   #endif
  
  
  

Mime
View raw message