Mercurial > hg > octave-kai > gnulib-hg
annotate tests/test-nonblocking-socket-child.c @ 17415:6550127da196
argp: typo fix
* lib/argp-help.c: Typo in comment.
author | Alexandre Duret-Lutz <adl@lrde.epita.fr> |
---|---|
date | Fri, 17 May 2013 19:01:14 +0200 |
parents | e542fd46ad6f |
children |
rev | line source |
---|---|
14590
e0d0a4052520
nonblocking: Add tests for sockets.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
1 /* Child program invoked by test-nonblocking-socket-main. |
e0d0a4052520
nonblocking: Add tests for sockets.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
2 |
17249
e542fd46ad6f
maint: update all copyright year number ranges
Eric Blake <eblake@redhat.com>
parents:
16201
diff
changeset
|
3 Copyright (C) 2011-2013 Free Software Foundation, Inc. |
14590
e0d0a4052520
nonblocking: Add tests for sockets.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
4 |
e0d0a4052520
nonblocking: Add tests for sockets.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
5 This program is free software: you can redistribute it and/or modify |
e0d0a4052520
nonblocking: Add tests for sockets.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
6 it under the terms of the GNU General Public License as published by |
e0d0a4052520
nonblocking: Add tests for sockets.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
7 the Free Software Foundation; either version 3 of the License, or |
e0d0a4052520
nonblocking: Add tests for sockets.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
8 (at your option) any later version. |
e0d0a4052520
nonblocking: Add tests for sockets.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
9 |
e0d0a4052520
nonblocking: Add tests for sockets.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
10 This program is distributed in the hope that it will be useful, |
e0d0a4052520
nonblocking: Add tests for sockets.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
11 but WITHOUT ANY WARRANTY; without even the implied warranty of |
e0d0a4052520
nonblocking: Add tests for sockets.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
e0d0a4052520
nonblocking: Add tests for sockets.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
13 GNU General Public License for more details. |
e0d0a4052520
nonblocking: Add tests for sockets.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
14 |
e0d0a4052520
nonblocking: Add tests for sockets.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
15 You should have received a copy of the GNU General Public License |
e0d0a4052520
nonblocking: Add tests for sockets.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
16 along with this program. If not, see <http://www.gnu.org/licenses/>. */ |
e0d0a4052520
nonblocking: Add tests for sockets.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
17 |
e0d0a4052520
nonblocking: Add tests for sockets.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
18 #include <config.h> |
e0d0a4052520
nonblocking: Add tests for sockets.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
19 |
e0d0a4052520
nonblocking: Add tests for sockets.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
20 #include <errno.h> |
e0d0a4052520
nonblocking: Add tests for sockets.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
21 #include <stdbool.h> |
e0d0a4052520
nonblocking: Add tests for sockets.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
22 #include <stdlib.h> |
e0d0a4052520
nonblocking: Add tests for sockets.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
23 #include <string.h> |
e0d0a4052520
nonblocking: Add tests for sockets.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
24 #include <unistd.h> |
e0d0a4052520
nonblocking: Add tests for sockets.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
25 #include <sys/time.h> |
e0d0a4052520
nonblocking: Add tests for sockets.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
26 |
e0d0a4052520
nonblocking: Add tests for sockets.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
27 #include "nonblocking.h" |
e0d0a4052520
nonblocking: Add tests for sockets.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
28 |
e0d0a4052520
nonblocking: Add tests for sockets.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
29 #include "macros.h" |
e0d0a4052520
nonblocking: Add tests for sockets.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
30 #include "socket-client.h" |
e0d0a4052520
nonblocking: Add tests for sockets.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
31 #include "test-nonblocking-socket.h" |
e0d0a4052520
nonblocking: Add tests for sockets.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
32 #define PROG_ROLE "child" |
e0d0a4052520
nonblocking: Add tests for sockets.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
33 #include "test-nonblocking-reader.h" |
e0d0a4052520
nonblocking: Add tests for sockets.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
34 |
e0d0a4052520
nonblocking: Add tests for sockets.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
35 int |
e0d0a4052520
nonblocking: Add tests for sockets.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
36 main (int argc, char *argv[]) |
e0d0a4052520
nonblocking: Add tests for sockets.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
37 { |
e0d0a4052520
nonblocking: Add tests for sockets.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
38 int test = atoi (argv[1]); |
e0d0a4052520
nonblocking: Add tests for sockets.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
39 int port = atoi (argv[2]); |
e0d0a4052520
nonblocking: Add tests for sockets.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
40 int client_socket; |
e0d0a4052520
nonblocking: Add tests for sockets.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
41 |
e0d0a4052520
nonblocking: Add tests for sockets.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
42 /* Create a client socket. */ |
e0d0a4052520
nonblocking: Add tests for sockets.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
43 client_socket = create_client_socket (port); |
e0d0a4052520
nonblocking: Add tests for sockets.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
44 |
e0d0a4052520
nonblocking: Add tests for sockets.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
45 /* Prepare the file descriptor. */ |
e0d0a4052520
nonblocking: Add tests for sockets.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
46 if (test & 2) |
e0d0a4052520
nonblocking: Add tests for sockets.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
47 ASSERT (set_nonblocking_flag (client_socket, true) >= 0); |
e0d0a4052520
nonblocking: Add tests for sockets.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
48 |
e0d0a4052520
nonblocking: Add tests for sockets.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
49 main_reader_loop (test, SOCKET_DATA_BLOCK_SIZE, client_socket); |
e0d0a4052520
nonblocking: Add tests for sockets.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
50 |
e0d0a4052520
nonblocking: Add tests for sockets.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
51 return 0; |
e0d0a4052520
nonblocking: Add tests for sockets.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
52 } |