Skip to content

Proposed TcpStream::open and TcpStream::open_timeout #13919

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
May 13, 2014
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 1 addition & 5 deletions src/compiletest/runtest.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ use util;

use std::io::File;
use std::io::fs;
use std::io::net::ip::{Ipv4Addr, SocketAddr};
use std::io::net::tcp;
use std::io::process::ProcessExit;
use std::io::process;
Expand Down Expand Up @@ -316,10 +315,7 @@ fn run_debuginfo_gdb_test(config: &config, props: &TestProps, testfile: &Path) {
//waiting 1 second for gdbserver start
timer::sleep(1000);
let result = task::try(proc() {
tcp::TcpStream::connect(SocketAddr {
ip: Ipv4Addr(127, 0, 0, 1),
port: 5039,
}).unwrap();
tcp::TcpStream::connect("127.0.0.1", 5039).unwrap();
});
if result.is_err() {
continue;
Expand Down
11 changes: 11 additions & 0 deletions src/liblibc/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -430,8 +430,19 @@ pub mod types {
pub ai_socktype: c_int,
pub ai_protocol: c_int,
pub ai_addrlen: socklen_t,

#[cfg(target_os = "linux")]
pub ai_addr: *sockaddr,

#[cfg(target_os = "linux")]
pub ai_canonname: *c_char,

#[cfg(target_os = "android")]
pub ai_canonname: *c_char,

#[cfg(target_os = "android")]
pub ai_addr: *sockaddr,

pub ai_next: *addrinfo,
}
pub struct sockaddr_un {
Expand Down
8 changes: 2 additions & 6 deletions src/libstd/io/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -83,11 +83,9 @@ Some examples of obvious things you might want to do

```rust,should_fail
# #![allow(unused_must_use)]
use std::io::net::ip::SocketAddr;
use std::io::net::tcp::TcpStream;

let addr = from_str::<SocketAddr>("127.0.0.1:8080").unwrap();
let mut socket = TcpStream::connect(addr).unwrap();
let mut socket = TcpStream::connect("127.0.0.1", 8080).unwrap();
socket.write(bytes!("GET / HTTP/1.0\n\n"));
let response = socket.read_to_end();
```
Expand All @@ -99,11 +97,9 @@ Some examples of obvious things you might want to do
# fn foo() {
# #![allow(dead_code)]
use std::io::{TcpListener, TcpStream};
use std::io::net::ip::{Ipv4Addr, SocketAddr};
use std::io::{Acceptor, Listener};

let addr = SocketAddr { ip: Ipv4Addr(127, 0, 0, 1), port: 80 };
let listener = TcpListener::bind(addr);
let listener = TcpListener::bind("127.0.0.1", 80);

// bind the listener to the specified address
let mut acceptor = listener.listen();
Expand Down
Loading