You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
First connect normally,but second is odd,
then resume,
python console log success,but actually rust code is not go into correspond code block.
If I use std::net::TcpListen with block listen, it's work as expect!
use mio::net::{TcpListener, TcpStream};
const SERVER: mio::Token = mio::Token(0);
fn main() {
let mut listener = TcpListener::bind("127.0.0.1:8080".parse().unwrap()).unwrap();
let mut poll = mio::Poll::new().unwrap();
let mut events = mio::Events::with_capacity(1024);
poll.registry()
.register(&mut listener, SERVER, mio::Interest::READABLE)
.unwrap();
loop {
poll.poll(&mut events, None).unwrap();
for event in events.iter() {
match event.token() {
SERVER => {
let (mut stream, addr) = listener.accept().unwrap();
println!("Accepted connection from: {}", addr);
}
_ => unreachable!(),
}
}
}
}
import socket
tcp_conn = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
tcp_conn.connect(('127.0.0.1', 8080))
while True:
data=input('Enter data to send: ')
if not data:
break
tcp_conn.send(data.encode())
data = tcp_conn.recv(1024)
if not data:
break
print('Received:', data.decode())
The text was updated successfully, but these errors were encountered:
I'm new,poll not work!
First connect normally,but second is odd,
then resume,
python console log success,but actually rust code is not go into correspond code block.
If I use std::net::TcpListen with block listen, it's work as expect!
The text was updated successfully, but these errors were encountered: