# Trait std::os::windows::io::FromRawSocket

1.1.0 · source ·

    pub trait FromRawSocket {
        // Required method
        unsafe fn from_raw_socket(sock: RawSocket) -> Self;
    }

Available on Windows only.
Expand description

Creates I/O objects from raw sockets.

## Required Methods§

source

#### unsafe fn from_raw_socket(sock: RawSocket) -> Self

Constructs a new I/O object from the specified raw socket.

This function is typically used to consume ownership of the socket given, passing responsibility for closing the socket to the returned object. When used in this way, the returned object will take responsibility for closing it when the object goes out of scope.

However, consuming ownership is not strictly required. Use a `From<OwnedSocket>::from` implementation for an API which strictly consumes ownership.

##### Safety

The `socket` passed in must:

- be an owned socket; in particular, it must be open.
- be a socket that may be freed via `closesocket`.

## Object Safety§

This trait is not object safe.

## Implementors§

source§

### impl FromRawSocket for TcpListener

source§

### impl FromRawSocket for TcpStream

source§

### impl FromRawSocket for UdpSocket

1.63.0 · source§

### impl FromRawSocket for OwnedSocket