@@ -102,7 +102,7 @@ impl ServerSocket{
102
102
/// #[tokio::main]
103
103
/// async fn main() -> Result<(), Box<dyn std::error::Error>> {
104
104
/// let port: u16 = 8080;
105
- /// match ServerSocket::new (port).await {
105
+ /// match ServerSocket::bind (port).await {
106
106
/// Ok(server) => {
107
107
/// println!("Server started on port {}", server.port);
108
108
/// }
@@ -131,9 +131,9 @@ impl ServerSocket{
131
131
/// - [`ServerSocketError`] for details on the possible errors.
132
132
/// - [`TcpListener`] for information on TCP listener behavior and usage.
133
133
/// ```rust
134
- /// pub async fn new (port: u16) -> Result<Self, ServerSocketError> {
134
+ /// pub async fn bind (port: u16) -> Result<Self, ServerSocketError> {
135
135
/// //localhost
136
- /// let localhost = Ipv4Addr::new (127, 0, 0, 1);
136
+ /// let localhost = Ipv4Addr::bind (127, 0, 0, 1);
137
137
/// let tcp_listener = TcpListener::bind((localhost, port)).await?; // ServerSocketError::IoError{source:<Error>}
138
138
///
139
139
/// Ok(ServerSocket {
@@ -143,7 +143,7 @@ impl ServerSocket{
143
143
/// })
144
144
/// }
145
145
/// ```
146
- pub async fn new ( port : u16 ) -> Result < Self , ServerSocketError > {
146
+ pub async fn bind ( port : u16 ) -> Result < Self , ServerSocketError > {
147
147
//localhost
148
148
let localhost = Ipv4Addr :: new ( 127 , 0 , 0 , 1 ) ;
149
149
let tcp_listener = TcpListener :: bind ( ( localhost, port) ) . await ?; // ServerSocketError::IoError{source:<Error>}
0 commit comments