Comments (7)
Question 1: I found that the WINDOWS system handles the network offline (unplug the peer network cable), and it takes about 8 seconds for the program to detect it.
This is outside of the scope of socket2. Socket2 doesn't do anything to change this.
Problem 2: During the brute force test, connections are constantly established and closed (shutdown). Socket2 does not call the WSACleanup function, so the connection fails.
We use the standard library for WSAStartup
, see
Lines 218 to 227 in 1f70523
from socket2.
Is there a reason why WSAStartup isn't called directly? Being tied to the standard library's startup/shutdown seems less versatile and more hacky.
from socket2.
Is there a reason why WSAStartup isn't called directly? Being tied to the standard library's startup/shutdown seems less versatile and more hacky.
It's not really possible as standard library always calls the WSAStartup
whenever a std::net
type is used. Furthermore it will panic if the call to WSAStartup
fails. So if socket2 would call WSAStartup
itself any usage of a type in std::net
would cause a panic.
from socket2.
WSAStartup
can be successfully called multiple times. The std only panics if the call fails. Trivial example:
fn main() {
init();
init();
init();
println!("Succesfully initialized");
unsafe {
assert_eq!(WSACleanup(), 0);
assert_eq!(WSACleanup(), 0);
assert_eq!(WSACleanup(), 0);
}
println!("Successfully shutdown");
}
fn init() {
unsafe {
let mut data: WSADATA = std::mem::zeroed();
let ret = WSAStartup(0x202, &mut data);
assert_eq!(ret, 0);
}
}
#[link(name="Ws2_32")]
extern "system" {
fn WSAStartup(wversionrequested: u16, lpwsadata: *mut WSADATA) -> i32;
fn WSACleanup() -> i32;
}
#[repr(C)]
#[allow(non_snake_case)]
pub struct WSADATA {
pub wVersion: u16,
pub wHighVersion: u16,
pub iMaxSockets: u16,
pub iMaxUdpDg: u16,
pub lpVendorInfo: *const u8,
pub szDescription: [u8; 257],
pub szSystemStatus: [u8; 129],
}
from socket2.
WSAStartup
can be successfully called multiple times. The std only panics if the call fails. Trivial example:
That certainly didn't use the be case. What Windows version are you using?
Some more background: tokio-rs/mio#1046, tokio-rs/mio#1029
from socket2.
I've not yet investigated those threads but it's documented behaviour so I'm surprised it didn't work.
An application can call WSAStartup more than once if it needs to obtain the WSADATA structure information more than once. On each such call, the application can specify any version number supported by the Winsock DLL...
An application must call the WSACleanup function for every successful time the WSAStartup function is called.
from socket2.
I've not yet investigated those threads but it's documented behaviour so I'm surprised it didn't work.
An application can call WSAStartup more than once if it needs to obtain the WSADATA structure information more than once. On each such call, the application can specify any version number supported by the Winsock DLL...
An application must call the WSACleanup function for every successful time the WSAStartup function is called.
This might have changed in later versions, I don't know, don't really keep track of it.
from socket2.
Related Issues (20)
- Add CI support for ESP-IDF
- msghdr as a private field in MsgHdr/MsgMutHdr HOT 2
- Set Socket interface using interface index HOT 1
- What happened to the `RAW` socket type? HOT 1
- Question: Possible to support architectures that only provide the `std::net` interface (and only TCP)? HOT 4
- Windows: `sa_family_t` should use `ADDRESS_FAMILY` from `windows-sys` HOT 5
- nonblocking connect HOT 6
- Set `ss_len` when creating `SockAddr` from std HOT 1
- bind_device succeeds, but subsequent sends fail with no such device or address. HOT 5
- QUESTION: How to special `laddr` when dialing connection? HOT 3
- Android support HOT 3
- don'tassign8080 port
- Currently socket2 has no way to set the DF bit on packets. The attached patch adds it. HOT 3
- Error: BoxSend(Os { code: 98, kind: AddrInUse, message: "Address already in use" }) HOT 2
- How to read EventExtra from the event? HOT 2
- socket() always fails on WSL1 due to unsupported SOCK_CLOEXEC flag HOT 5
- Support for {recv,send}mmsg HOT 2
- New release HOT 1
- socket error HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from socket2.