mirror of
https://github.com/jart/cosmopolitan.git
synced 2025-05-20 12:30:09 +00:00
Remove SOCK_NONBLOCK from Echo Server example
See #102 for further explanation.
This commit is contained in:
parent
9367253b4d
commit
754974faaa
1 changed files with 3 additions and 5 deletions
|
@ -179,9 +179,8 @@ void BeginListeningForIncomingTraffic(void) {
|
||||||
for (i = 0; i < g_sockets.i; ++i) {
|
for (i = 0; i < g_sockets.i; ++i) {
|
||||||
int yes = 1;
|
int yes = 1;
|
||||||
struct Socket *s = &g_sockets.p[i];
|
struct Socket *s = &g_sockets.p[i];
|
||||||
CHECK_NE(-1L,
|
CHECK_NE(-1L, (g_polls.p[i].fd = s->fd =
|
||||||
(g_polls.p[i].fd = s->fd = socket(
|
socket(s->addr.sin_family, s->type, s->protocol)));
|
||||||
s->addr.sin_family, s->type | SOCK_NONBLOCK, s->protocol)));
|
|
||||||
CHECK_NE(-1L,
|
CHECK_NE(-1L,
|
||||||
setsockopt(s->fd, SOL_SOCKET, SO_REUSEPORT, &yes, sizeof(yes)));
|
setsockopt(s->fd, SOL_SOCKET, SO_REUSEPORT, &yes, sizeof(yes)));
|
||||||
CHECK_NE(-1, bind(s->fd, &s->addr, sizeof(s->addr)));
|
CHECK_NE(-1, bind(s->fd, &s->addr, sizeof(s->addr)));
|
||||||
|
@ -202,8 +201,7 @@ void AcceptConnection(size_t i) {
|
||||||
client.type = server->type;
|
client.type = server->type;
|
||||||
client.protocol = server->protocol;
|
client.protocol = server->protocol;
|
||||||
uint32_t addrsize = sizeof(client.addr);
|
uint32_t addrsize = sizeof(client.addr);
|
||||||
CHECK_NE(-1L, (client.fd = accept4(server->fd, &client.addr, &addrsize,
|
CHECK_NE(-1L, (client.fd = accept(server->fd, &client.addr, &addrsize)));
|
||||||
SOCK_NONBLOCK)));
|
|
||||||
LOGF("%s accepted %s", gc(DescribeSocket(server)),
|
LOGF("%s accepted %s", gc(DescribeSocket(server)),
|
||||||
gc(DescribeSocket(&client)));
|
gc(DescribeSocket(&client)));
|
||||||
AddSocket(&client);
|
AddSocket(&client);
|
||||||
|
|
Loading…
Add table
Reference in a new issue