Skip to main content

base_scheduler/
socket_open.rs

1// Released under the MIT License.
2// Copyright, 2026, by Samuel Williams.
3
4use super::SocketOperation;
5use crate::{Cancellation, OperationResult, SocketDomain, SocketProtocol, SocketType};
6use std::future::Future;
7
8/// Create an unbound IP socket through the scheduler.
9pub trait SocketOpen: SocketOperation {
10    /// Open a nonblocking socket without binding, listening, or connecting. `None` selects the OS default protocol for the requested domain and type.
11    fn socket_open(
12        &self,
13        domain: SocketDomain,
14        kind: SocketType,
15        protocol: Option<SocketProtocol>,
16        cancellation: &Cancellation,
17    ) -> impl Future<Output = OperationResult<Self::Socket>> + Send;
18}