Apache HTTPD
sockchild.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 <stdlib.h>
18#include "testsock.h"
19#include "apr_network_io.h"
20#include "apr_pools.h"
21
22int main(int argc, char *argv[])
23{
26 apr_status_t rv;
28
32
33 if (argc < 3) {
34 exit(-1);
35 }
36
37 rv = apr_sockaddr_info_get(&remote_sa, argv[2], APR_UNSPEC, 8021, 0, p);
38 if (rv != APR_SUCCESS) {
39 exit(-1);
40 }
41
43 p) != APR_SUCCESS) {
44 exit(-1);
45 }
46
48 if (rv) {
49 exit(-1);
50 }
51
53
54 if (!strcmp("read", argv[1])) {
55 char datarecv[STRLEN];
57 apr_status_t rv;
58
62 if (APR_STATUS_IS_TIMEUP(rv)) {
64 }
65
66 if (strcmp(datarecv, DATASTR)) {
67 exit(-1);
68 }
69
70 exit((int)length);
71 }
72 else if (!strcmp("write", argv[1])
73 || !strcmp("write_after_delay", argv[1])) {
74 apr_size_t length = strlen(DATASTR);
75
76 if (!strcmp("write_after_delay", argv[1])) {
78 }
79
81
83 exit((int)length);
84 }
85 else if (!strcmp("close", argv[1])) {
87 exit(0);
88 }
89 exit(-1);
90}
APR Network library.
APR memory allocation.
#define APR_STATUS_IS_TIMEUP(s)
Definition apr_errno.h:534
int apr_off_t * length
apr_size_t size
#define APR_SUCCESS
Definition apr_errno.h:225
int apr_status_t
Definition apr_errno.h:44
apr_pool_t int argc
Definition apr_getopt.h:104
apr_socket_t * sock
#define APR_UNSPEC
#define apr_pool_create(newpool, parent)
Definition apr_pools.h:322
#define apr_time_from_sec(sec)
Definition apr_time.h:78
apr_pool_t * p
Definition md_event.c:32
const char * argv[3]
return NULL
Definition mod_so.c:359
int main(void)
Definition occhild.c:9
#define STRLEN
Definition testsock.h:21
#define DATASTR
Definition testsock.h:20
#define SOCKET_TIMEOUT
Definition testsock.h:31
apr_status_t apr_socket_send(apr_socket_t *sock, const char *buf, apr_size_t *len)
Definition sendrecv.c:30
apr_status_t apr_socket_recv(apr_socket_t *sock, char *buf, apr_size_t *len)
Definition sendrecv.c:70
apr_status_t apr_socket_close(apr_socket_t *thesocket)
Definition sockets.c:211
apr_status_t apr_socket_connect(apr_socket_t *sock, apr_sockaddr_t *sa)
Definition sockets.c:388
apr_status_t apr_socket_create(apr_socket_t **new, int ofamily, int type, int protocol, apr_pool_t *cont)
Definition sockets.c:116
apr_status_t apr_socket_timeout_set(apr_socket_t *sock, apr_interval_time_t t)
Definition sockopt.c:75