test-socket-buffer-size.c
Go to the documentation of this file.
1 /* Copyright Joyent, Inc. and other Node contributors. All rights reserved.
2  *
3  * Permission is hereby granted, free of charge, to any person obtaining a copy
4  * of this software and associated documentation files (the "Software"), to
5  * deal in the Software without restriction, including without limitation the
6  * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
7  * sell copies of the Software, and to permit persons to whom the Software is
8  * furnished to do so, subject to the following conditions:
9  *
10  * The above copyright notice and this permission notice shall be included in
11  * all copies or substantial portions of the Software.
12  *
13  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16  * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
18  * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
19  * IN THE SOFTWARE.
20  */
21 
22 #include "uv.h"
23 #include "task.h"
24 
25 #include <stdio.h>
26 #include <stdlib.h>
27 #include <string.h>
28 
29 static uv_udp_t udp;
30 static uv_tcp_t tcp;
31 static int close_cb_called;
32 
33 
34 static void close_cb(uv_handle_t* handle) {
36 }
37 
38 
40  int value;
41 
42  value = 0;
44  ASSERT(value > 0);
45 
46  value = 10000;
48 
49  value = 0;
51  /* linux sets double the value */
52  ASSERT(value == 10000 || value == 20000);
53 }
54 
55 
56 TEST_IMPL(socket_buffer_size) {
57  struct sockaddr_in addr;
58 
59  ASSERT(0 == uv_ip4_addr("127.0.0.1", TEST_PORT, &addr));
60 
62  ASSERT(0 == uv_tcp_bind(&tcp, (struct sockaddr*) &addr, 0));
65 
67  ASSERT(0 == uv_udp_bind(&udp, (struct sockaddr*) &addr, 0));
70 
72 
73  ASSERT(close_cb_called == 2);
74 
76  return 0;
77 }
task.h
string.h
ASSERT
#define ASSERT(expr)
Definition: task.h:102
uv_run
UV_EXTERN int uv_run(uv_loop_t *, uv_run_mode mode)
Definition: unix/core.c:361
uv_tcp_bind
UV_EXTERN int uv_tcp_bind(uv_tcp_t *handle, const struct sockaddr *addr, unsigned int flags)
Definition: uv-common.c:277
TEST_PORT
#define TEST_PORT
Definition: task.h:53
uv_close
UV_EXTERN void uv_close(uv_handle_t *handle, uv_close_cb close_cb)
Definition: unix/core.c:112
close_cb
static void close_cb(uv_handle_t *handle)
Definition: test-socket-buffer-size.c:34
uv_ip4_addr
UV_EXTERN int uv_ip4_addr(const char *ip, int port, struct sockaddr_in *addr)
Definition: uv-common.c:221
uv_udp_init
UV_EXTERN int uv_udp_init(uv_loop_t *, uv_udp_t *handle)
Definition: unix/udp.c:988
uv_default_loop
UV_EXTERN uv_loop_t * uv_default_loop(void)
Definition: uv-common.c:733
UV_RUN_DEFAULT
@ UV_RUN_DEFAULT
Definition: uv.h:254
uv_udp_s
Definition: uv.h:629
tcp
static uv_tcp_t tcp
Definition: test-socket-buffer-size.c:30
check_buffer_size
static void check_buffer_size(uv_handle_t *handle)
Definition: test-socket-buffer-size.c:39
uv_tcp_init
UV_EXTERN int uv_tcp_init(uv_loop_t *, uv_tcp_t *handle)
Definition: unix/tcp.c:143
uv_tcp_s
Definition: uv.h:544
uv_recv_buffer_size
UV_EXTERN int uv_recv_buffer_size(uv_handle_t *handle, int *value)
Definition: uv-common.c:554
value
const char * value
Definition: hpack_parser_table.cc:165
uv.h
MAKE_VALGRIND_HAPPY
#define MAKE_VALGRIND_HAPPY()
Definition: task.h:229
uv_udp_bind
UV_EXTERN int uv_udp_bind(uv_udp_t *handle, const struct sockaddr *addr, unsigned int flags)
Definition: uv-common.c:296
TEST_IMPL
TEST_IMPL(socket_buffer_size)
Definition: test-socket-buffer-size.c:56
handle
static csh handle
Definition: test_arm_regression.c:16
uv_handle_s
Definition: uv.h:441
close_cb_called
static int close_cb_called
Definition: test-socket-buffer-size.c:31
udp
static uv_udp_t udp
Definition: test-socket-buffer-size.c:29
addr
struct sockaddr_in addr
Definition: libuv/docs/code/tcp-echo-server/main.c:10


grpc
Author(s):
autogenerated on Thu Mar 13 2025 03:01:30