mirror of
https://github.com/ziglang/zig.git
synced 2026-01-20 22:35:24 +00:00
x/os: {read, write}Vectorized() -> {read, write}Message()
This commit is contained in:
parent
9ba65592d6
commit
7b6ec3e354
@ -2111,10 +2111,7 @@ test "parse into struct with duplicate field" {
|
||||
const ballast = try testing.allocator.alloc(u64, 1);
|
||||
defer testing.allocator.free(ballast);
|
||||
|
||||
const options_first = ParseOptions{
|
||||
.allocator = testing.allocator,
|
||||
.duplicate_field_behavior = .UseFirst,
|
||||
};
|
||||
const options_first = ParseOptions{ .allocator = testing.allocator, .duplicate_field_behavior = .UseFirst };
|
||||
|
||||
const options_last = ParseOptions{
|
||||
.allocator = testing.allocator,
|
||||
|
||||
@ -145,15 +145,15 @@ pub const Client = struct {
|
||||
/// Writes multiple I/O vectors with a prepended message header to the socket
|
||||
/// with a set of flags specified. It returns the number of bytes that are
|
||||
/// written to the socket.
|
||||
pub fn writeVectorized(self: Client, msg: Socket.Message, flags: u32) !usize {
|
||||
return self.socket.writeVectorized(msg, flags);
|
||||
pub fn writeMessage(self: Client, msg: Socket.Message, flags: u32) !usize {
|
||||
return self.socket.writeMessage(msg, flags);
|
||||
}
|
||||
|
||||
/// Read multiple I/O vectors with a prepended message header from the socket
|
||||
/// with a set of flags specified. It returns the number of bytes that were
|
||||
/// read into the buffer provided.
|
||||
pub fn readVectorized(self: Client, msg: *Socket.Message, flags: u32) !usize {
|
||||
return self.socket.readVectorized(msg, flags);
|
||||
pub fn readMessage(self: Client, msg: *Socket.Message, flags: u32) !usize {
|
||||
return self.socket.readMessage(msg, flags);
|
||||
}
|
||||
|
||||
/// Query and return the latest cached error on the client's underlying socket.
|
||||
@ -400,7 +400,7 @@ test "tcp/client: read and write multiple vectors" {
|
||||
defer conn.deinit();
|
||||
|
||||
const message = "hello world";
|
||||
_ = try conn.client.writeVectorized(Socket.Message.fromBuffers(&[_]Buffer{
|
||||
_ = try conn.client.writeMessage(Socket.Message.fromBuffers(&[_]Buffer{
|
||||
Buffer.from(message[0 .. message.len / 2]),
|
||||
Buffer.from(message[message.len / 2 ..]),
|
||||
}), 0);
|
||||
@ -410,7 +410,7 @@ test "tcp/client: read and write multiple vectors" {
|
||||
Buffer.from(buf[0 .. message.len / 2]),
|
||||
Buffer.from(buf[message.len / 2 ..]),
|
||||
});
|
||||
_ = try client.readVectorized(&msg, 0);
|
||||
_ = try client.readMessage(&msg, 0);
|
||||
|
||||
try testing.expectEqualStrings(message, buf[0..message.len]);
|
||||
}
|
||||
|
||||
@ -78,14 +78,14 @@ pub fn Mixin(comptime Socket: type) type {
|
||||
/// Writes multiple I/O vectors with a prepended message header to the socket
|
||||
/// with a set of flags specified. It returns the number of bytes that are
|
||||
/// written to the socket.
|
||||
pub fn writeVectorized(self: Socket, msg: Socket.Message, flags: u32) !usize {
|
||||
pub fn writeMessage(self: Socket, msg: Socket.Message, flags: u32) !usize {
|
||||
return os.sendmsg(self.fd, msg, flags);
|
||||
}
|
||||
|
||||
/// Read multiple I/O vectors with a prepended message header from the socket
|
||||
/// with a set of flags specified. It returns the number of bytes that were
|
||||
/// read into the buffer provided.
|
||||
pub fn readVectorized(self: Socket, msg: *Socket.Message, flags: u32) !usize {
|
||||
pub fn readMessage(self: Socket, msg: *Socket.Message, flags: u32) !usize {
|
||||
while (true) {
|
||||
const rc = os.system.recvmsg(self.fd, msg, @intCast(c_int, flags));
|
||||
return switch (os.errno(rc)) {
|
||||
|
||||
@ -254,7 +254,7 @@ pub fn Mixin(comptime Socket: type) type {
|
||||
/// Writes multiple I/O vectors with a prepended message header to the socket
|
||||
/// with a set of flags specified. It returns the number of bytes that are
|
||||
/// written to the socket.
|
||||
pub fn writeVectorized(self: Socket, msg: Socket.Message, flags: u32) !usize {
|
||||
pub fn writeMessage(self: Socket, msg: Socket.Message, flags: u32) !usize {
|
||||
const call = try windows.loadWinsockExtensionFunction(ws2_32.LPFN_WSASENDMSG, self.fd, ws2_32.WSAID_WSASENDMSG);
|
||||
|
||||
var num_bytes: u32 = undefined;
|
||||
@ -291,7 +291,7 @@ pub fn Mixin(comptime Socket: type) type {
|
||||
/// Read multiple I/O vectors with a prepended message header from the socket
|
||||
/// with a set of flags specified. It returns the number of bytes that were
|
||||
/// read into the buffer provided.
|
||||
pub fn readVectorized(self: Socket, msg: *Socket.Message, flags: u32) !usize {
|
||||
pub fn readMessage(self: Socket, msg: *Socket.Message, flags: u32) !usize {
|
||||
const call = try windows.loadWinsockExtensionFunction(ws2_32.LPFN_WSARECVMSG, self.fd, ws2_32.WSAID_WSARECVMSG);
|
||||
|
||||
var num_bytes: u32 = undefined;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user