fail to find EAGAIN by experiment
This commit is contained in:
parent
2fea95e100
commit
56715c3079
2 changed files with 39 additions and 0 deletions
27
eagain.c
Normal file
27
eagain.c
Normal file
|
@ -0,0 +1,27 @@
|
|||
#include <fcntl.h>
|
||||
#include <stdlib.h>
|
||||
#include <sys/socket.h>
|
||||
#include <sys/un.h>
|
||||
#include <unistd.h>
|
||||
|
||||
char path[] = "eagain.sock";
|
||||
char spam[0xffff0];
|
||||
|
||||
int main() {
|
||||
int sock = socket(AF_UNIX, SOCK_STREAM, 0);
|
||||
fcntl(sock, F_SETFL, O_NONBLOCK);
|
||||
struct sockaddr_un addr;
|
||||
addr.sun_family = AF_UNIX;
|
||||
int i = 0;
|
||||
while (1) {
|
||||
addr.sun_path[i] = path[i];
|
||||
if (path[i] == 0) break;
|
||||
i += 1;
|
||||
}
|
||||
connect(sock, (struct sockaddr*)&addr, sizeof(addr));
|
||||
//shutdown(sock, SHUT_WR);
|
||||
for (i = 0; i < 9999; i += 1) {
|
||||
int result = write(sock, spam, 0xffff);
|
||||
if (result < 0) exit(1);
|
||||
}
|
||||
}
|
12
eagain.zig
Normal file
12
eagain.zig
Normal file
|
@ -0,0 +1,12 @@
|
|||
const std = @import("std");
|
||||
|
||||
const path = "eagain.sock";
|
||||
const spam: [0xffff]u8 = undefined;
|
||||
|
||||
pub fn main() !void {
|
||||
const stream = try std.net.connectUnixSocket(path);
|
||||
_ = try std.posix.fcntl(stream.handle, std.c.F.SETFL, std.c.SOCK.NONBLOCK);
|
||||
for (0..99999) |_| {
|
||||
_ = try stream.write(&spam);
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue