Skip to content

Commit d818ea8

Browse files
committed
core::rt: Listener constructors are called and return a
1 parent bcb3cfb commit d818ea8

File tree

3 files changed

+30
-3
lines changed

3 files changed

+30
-3
lines changed

src/libcore/rt/io/net/tcp.rs

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,11 +40,38 @@ impl Close for TcpStream {
4040
pub struct TcpListener;
4141

4242
impl TcpListener {
43-
pub fn new(_addr: IpAddr) -> TcpListener {
43+
pub fn bind(_addr: IpAddr) -> Result<TcpListener, IoError> {
4444
fail!()
4545
}
4646
}
4747

4848
impl Listener<TcpStream> for TcpListener {
4949
fn accept(&mut self) -> Option<TcpStream> { fail!() }
5050
}
51+
52+
#[cfg(test)]
53+
mod test {
54+
use super::*;
55+
use rt::test::*;
56+
57+
#[test] #[ignore]
58+
fn smoke_test() {
59+
/*do run_in_newsched_task {
60+
let addr = next_test_ip4();
61+
62+
do spawn_immediately {
63+
let listener = TcpListener::bind(addr);
64+
do listener.accept() {
65+
let mut buf = [0];
66+
listener.read(buf);
67+
assert!(buf[0] == 99);
68+
}
69+
}
70+
71+
do spawn_immediately {
72+
let stream = TcpStream::connect(addr);
73+
stream.write([99]);
74+
}
75+
}*/
76+
}
77+
}

src/libcore/rt/io/net/udp.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ impl Close for UdpStream {
4040
pub struct UdpListener;
4141

4242
impl UdpListener {
43-
pub fn new(_addr: IpAddr) -> UdpListener {
43+
pub fn bind(_addr: IpAddr) -> Result<UdpListener, IoError> {
4444
fail!()
4545
}
4646
}

src/libcore/rt/io/net/unix.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ impl Close for UnixStream {
4040
pub struct UnixListener;
4141

4242
impl UnixListener {
43-
pub fn new<P: PathLike>(_path: &P) -> UnixListener {
43+
pub fn bind<P: PathLike>(_path: &P) -> Result<UnixListener, IoError> {
4444
fail!()
4545
}
4646
}

0 commit comments

Comments
 (0)