1
/* Copyright 2000-2005 The Apache Software Foundation or its licensors, as
4
* Licensed under the Apache License, Version 2.0 (the "License");
5
* you may not use this file except in compliance with the License.
6
* You may obtain a copy of the License at
8
* http://www.apache.org/licenses/LICENSE-2.0
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.
19
#include "apr_network_io.h"
20
#include "apr_pools.h"
22
int main(int argc, char *argv[])
27
apr_sockaddr_t *remote_sa;
30
atexit(apr_terminate);
31
apr_pool_create(&p, NULL);
37
rv = apr_sockaddr_info_get(&remote_sa, "127.0.0.1", APR_UNSPEC, 8021, 0, p);
38
if (rv != APR_SUCCESS) {
42
if (apr_socket_create(&sock, remote_sa->family, SOCK_STREAM, 0,
47
rv = apr_socket_timeout_set(sock, apr_time_from_sec(3));
52
apr_socket_connect(sock, remote_sa);
54
if (!strcmp("read", argv[1])) {
55
char datarecv[STRLEN];
56
apr_size_t length = STRLEN;
59
memset(datarecv, 0, STRLEN);
60
rv = apr_socket_recv(sock, datarecv, &length);
61
apr_socket_close(sock);
62
if (APR_STATUS_IS_TIMEUP(rv)) {
66
if (strcmp(datarecv, DATASTR)) {
72
else if (!strcmp("write", argv[1])) {
73
apr_size_t length = strlen(DATASTR);
74
apr_socket_send(sock, DATASTR, &length);
76
apr_socket_close(sock);