|
|
|
@ -2,15 +2,28 @@ use libctru::{socInit, socExit};
@@ -2,15 +2,28 @@ use libctru::{socInit, socExit};
|
|
|
|
|
|
|
|
|
|
use libc::{memalign, free}; |
|
|
|
|
|
|
|
|
|
/// Soc service. Initializing this service will enable the use of network sockets and utilities
|
|
|
|
|
/// such as those found in `std::net`. The service will be closed when this struct is is dropped.
|
|
|
|
|
pub struct Soc { |
|
|
|
|
soc_mem: *mut u32, |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
impl Soc { |
|
|
|
|
/// Initialize the Soc service with a default buffer size of 0x100000 bytes
|
|
|
|
|
///
|
|
|
|
|
/// # Errors
|
|
|
|
|
///
|
|
|
|
|
/// This function will return an error if the `Soc` service is already initialized
|
|
|
|
|
pub fn init() -> ::Result<Soc> { |
|
|
|
|
Soc::init_with_buffer_size(0x100000) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/// Initialize the Soc service with a custom buffer size in bytes. The size should be
|
|
|
|
|
/// 0x100000 bytes or greater.
|
|
|
|
|
///
|
|
|
|
|
/// # Errors
|
|
|
|
|
///
|
|
|
|
|
/// This function will return an error if the `Soc` service is already initialized
|
|
|
|
|
pub fn init_with_buffer_size(num_bytes: usize) -> ::Result<Soc> { |
|
|
|
|
unsafe { |
|
|
|
|
let soc_mem = memalign(0x1000, num_bytes) as *mut u32; |
|
|
|
|