Apache HTTPD
sendrecv_udp.c
Go to the documentation of this file.
1/* Licensed to the Apache Software Foundation (ASF) under one or more
2 * contributor license agreements. See the NOTICE file distributed with
3 * this work for additional information regarding copyright ownership.
4 * The ASF licenses this file to You under the Apache License, Version 2.0
5 * (the "License"); you may not use this file except in compliance with
6 * the License. You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17#include "apr_arch_networkio.h"
18#include "apr_errno.h"
19#include "apr_general.h"
20#include "apr_network_io.h"
21#include "apr_support.h"
22#include "apr_lib.h"
23#include <sys/time.h>
24
25
28 apr_int32_t flags, const char *buf,
30{
31 apr_ssize_t rv;
32 int serrno;
33
34 do {
35 rv = sendto(sock->socketdes, buf, (*len), flags,
36 (struct sockaddr*)&where->sa,
37 where->salen);
38 } while (rv == -1 && (serrno = sock_errno()) == EINTR);
39
40 if (rv == -1 && serrno == SOCEWOULDBLOCK && sock->timeout != 0) {
42
43 if (arv != APR_SUCCESS) {
44 *len = 0;
45 return arv;
46 } else {
47 do {
48 rv = sendto(sock->socketdes, buf, *len, flags,
49 (const struct sockaddr*)&where->sa,
50 where->salen);
51 } while (rv == -1 && (serrno = sock_errno()) == SOCEINTR);
52 }
53 }
54
55 if (rv == -1) {
56 *len = 0;
58 }
59
60 *len = rv;
61 return APR_SUCCESS;
62}
63
64
65
68 apr_int32_t flags, char *buf,
70{
71 apr_ssize_t rv;
72 int serrno;
73
74 do {
75 rv = recvfrom(sock->socketdes, buf, (*len), flags,
76 (struct sockaddr*)&from->sa, &from->salen);
77 } while (rv == -1 && (serrno = sock_errno()) == EINTR);
78
79 if (rv == -1 && serrno == SOCEWOULDBLOCK && sock->timeout != 0) {
81
82 if (arv != APR_SUCCESS) {
83 *len = 0;
84 return arv;
85 } else {
86 do {
88 (struct sockaddr*)&from->sa, &from->salen);
89 } while (rv == -1 && (serrno = sock_errno()) == EINTR);
90 }
91 }
92
93 if (rv == -1) {
94 (*len) = 0;
96 }
97
98 (*len) = rv;
99
100 if (rv == 0 && sock->type == SOCK_STREAM)
101 return APR_EOF;
102
103 return APR_SUCCESS;
104}
const char apr_size_t len
Definition ap_regex.h:187
#define recvfrom
#define sendto
#define sock_errno
APR Error Codes.
APR Miscellaneous library routines.
APR general purpose library routines.
APR Network library.
APR Support functions.
const unsigned char * buf
Definition util_md5.h:50
#define APR_EOF
Definition apr_errno.h:461
const char apr_ssize_t int flags
Definition apr_encode.h:168
const void apr_status_t(*) apr_status_t(* APR_DECLARE)(void) apr_pool_pre_cleanup_register(apr_pool_t *p
Definition apr_pools.h:646
apr_size_t size
#define APR_FROM_OS_ERROR(e)
Definition apr_errno.h:1214
#define APR_SUCCESS
Definition apr_errno.h:225
int apr_status_t
Definition apr_errno.h:44
apr_seek_where_t where
apr_sockaddr_t * sockaddr
apr_socket_t * sock
apr_status_t apr_wait_for_io_or_timeout(apr_file_t *f, apr_socket_t *s, int for_read)
return NULL
Definition mod_so.c:359
#define SOCEINTR
union apr_sockaddr_t::@55 sa
apr_socklen_t salen
apr_interval_time_t timeout
apr_status_t apr_socket_sendto(apr_socket_t *sock, apr_sockaddr_t *where, apr_int32_t flags, const char *buf, apr_size_t *len)
Definition sendrecv.c:112
apr_status_t apr_socket_recvfrom(apr_sockaddr_t *from, apr_socket_t *sock, apr_int32_t flags, char *buf, apr_size_t *len)
Definition sendrecv.c:146