Skip to content

Commit

Permalink
std::net: fix io handling
Browse files Browse the repository at this point in the history
  • Loading branch information
mertcandav committed Sep 21, 2024
1 parent cfd6ce3 commit c229afd
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 9 deletions.
6 changes: 3 additions & 3 deletions std/net/sock_unix.jule
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@
// Use of this source code is governed by a BSD 3-Clause
// license that can be found in the LICENSE file.

use runtime for std::runtime
use mem for std::mem
use sys for std::sys
use time for std::time
use std::jule::integrated::{UnsignedInt}
use zsys for std::internal::zsys

type netHandle: int
type addrLen: u32
Expand Down Expand Up @@ -90,7 +90,7 @@ lookup:
}

fn recvfrom(&conn: UdpConn, mut &buf: []byte)!: int {
zsys::HandleRW(buf)
runtime::handleRW(buf)
if conn.v6 {
addrLen := addrLen(mem::SizeOf(conn.sockaddr6))
n := unsafe { sys::Recvfrom(conn.handle, &buf[0], uint(len(buf)), 0, (*sys::Sockaddr)(&conn.sockaddr6), &addrLen) }
Expand All @@ -108,7 +108,7 @@ fn recvfrom(&conn: UdpConn, mut &buf: []byte)!: int {
}

fn sendto(&conn: UdpConn, &buf: []byte)!: int {
zsys::HandleRW(buf)
runtime::handleRW(buf)
if conn.v6 {
addrLen := addrLen(mem::SizeOf(conn.sockaddr6))
n := unsafe { sys::Sendto(conn.handle, &buf[0], uint(len(buf)), 0, (*sys::Sockaddr)(&conn.sockaddr6), addrLen) }
Expand Down
6 changes: 3 additions & 3 deletions std/net/sock_windows.jule
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@
// Use of this source code is governed by a BSD 3-Clause
// license that can be found in the LICENSE file.

use runtime for std::runtime
use mem for std::mem
use sys for std::sys
use time for std::time
use std::jule::integrated::{Char, Int, Long, UnsignedLong}
use zsys for std::internal::zsys

type netHandle: uint
type addrLen: Int
Expand Down Expand Up @@ -78,7 +78,7 @@ unsafe fn connectSocket(handle: netHandle, sockAddr: *sys::Sockaddr, sockLen: ui
}

fn recvfrom(&conn: UdpConn, mut &buf: []byte)!: int {
zsys::HandleRW(buf)
runtime::handleRW(buf)
if conn.v6 {
addrLen := addrLen(mem::SizeOf(conn.sockaddr6))
n := unsafe { sys::Recvfrom(conn.handle, &buf[0], len(buf), 0, (*sys::Sockaddr)(&conn.sockaddr6), &addrLen) }
Expand All @@ -96,7 +96,7 @@ fn recvfrom(&conn: UdpConn, mut &buf: []byte)!: int {
}

fn sendto(&conn: UdpConn, &buf: []byte)!: int {
zsys::HandleRW(buf)
runtime::handleRW(buf)
if conn.v6 {
addrLen := addrLen(mem::SizeOf(conn.sockaddr6))
n := unsafe { sys::Sendto(conn.handle, &buf[0], len(buf), 0, (*sys::Sockaddr)(&conn.sockaddr6), addrLen) }
Expand Down
6 changes: 3 additions & 3 deletions std/net/tcp_conn.jule
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@
// Use of this source code is governed by a BSD 3-Clause
// license that can be found in the LICENSE file.

use runtime for std::runtime
use io for std::io
use time for std::time
use sys for std::sys
use zsys for std::internal::zsys

// TCP connection.
// In most cases, represents TCP client.
Expand Down Expand Up @@ -38,7 +38,7 @@ impl TcpConn {
if len(buf) == 0 {
ret 0
}
zsys::HandleRW(buf)
runtime::handleRW(buf)
n := unsafe { sys::Recv(self.handle, &buf[0], uint(len(buf)), 0) }
if n > 0 {
ret n
Expand All @@ -59,7 +59,7 @@ impl TcpConn {
if len(buf) == 0 {
ret 0
}
zsys::HandleRW(buf)
runtime::handleRW(buf)
n := unsafe { sys::Send(self.handle, &buf[0], uint(len(buf)), 0) }
if n < 0 {
error(lastErrorCode())
Expand Down

0 comments on commit c229afd

Please sign in to comment.