#[cfg(unix)] pub type sock_t = super::file::fd_t;
pub fn htons(u: u16) -> u16 {
- u.to_big_endian()
+ u.to_be()
}
pub fn ntohs(u: u16) -> u16 {
- Int::from_big_endian(u)
+ Int::from_be(u)
}
enum InAddr {
(c as u32 << 8) |
(d as u32 << 0);
InAddr(libc::in_addr {
- s_addr: Int::from_big_endian(ip)
+ s_addr: Int::from_be(ip)
})
}
rtio::Ipv6Addr(a, b, c, d, e, f, g, h) => {
fn setsockopt<T>(fd: sock_t, opt: libc::c_int, val: libc::c_int,
payload: T) -> IoResult<()> {
unsafe {
- let payload = &payload as *T as *libc::c_void;
+ let payload = &payload as *const T as *const libc::c_void;
let ret = libc::setsockopt(fd, opt, val,
payload,
mem::size_of::<T>() as libc::socklen_t);
let storage: &libc::sockaddr_in = unsafe {
mem::transmute(storage)
};
- let ip = (storage.sin_addr.s_addr as u32).to_big_endian();
+ let ip = (storage.sin_addr.s_addr as u32).to_be();
let a = (ip >> 24) as u8;
let b = (ip >> 16) as u8;
let c = (ip >> 8) as u8;
let ret = TcpStream::new(Inner::new(fd));
let (addr, len) = addr_to_sockaddr(addr);
- let addrp = &addr as *_ as *libc::sockaddr;
+ let addrp = &addr as *const _ as *const libc::sockaddr;
let len = len as libc::socklen_t;
match timeout {
seconds as libc::c_int)
}
#[cfg(target_os = "freebsd")]
+ #[cfg(target_os = "dragonfly")]
fn set_tcp_keepalive(&mut self, seconds: uint) -> IoResult<()> {
setsockopt(self.fd(), libc::IPPROTO_TCP, libc::TCP_KEEPIDLE,
seconds as libc::c_int)
}
- #[cfg(not(target_os = "macos"), not(target_os = "ios"), not(target_os = "freebsd"))]
+ #[cfg(not(target_os = "macos"), not(target_os = "ios"), not(target_os = "freebsd"),
+ not(target_os = "dragonfly"))]
fn set_tcp_keepalive(&mut self, _seconds: uint) -> IoResult<()> {
Ok(())
}
fn write(&mut self, buf: &[u8]) -> IoResult<()> {
let fd = self.fd();
let dolock = || self.lock_nonblocking();
- let dowrite = |nb: bool, buf: *u8, len: uint| unsafe {
+ let dowrite = |nb: bool, buf: *const u8, len: uint| unsafe {
let flags = if nb {c::MSG_DONTWAIT} else {0};
libc::send(fd,
buf as *mut libc::c_void,
let ret = TcpListener { inner: Inner::new(fd) };
let (addr, len) = addr_to_sockaddr(addr);
- let addrp = &addr as *_ as *libc::sockaddr;
+ let addrp = &addr as *const _ as *const libc::sockaddr;
let len = len as libc::socklen_t;
// On platforms with Berkeley-derived sockets, this allows
}
impl rtio::RtioTcpListener for TcpListener {
- fn listen(~self) -> IoResult<Box<rtio::RtioTcpAcceptor + Send>> {
+ fn listen(self: Box<TcpListener>)
+ -> IoResult<Box<rtio::RtioTcpAcceptor + Send>> {
self.native_listen(128).map(|a| {
box a as Box<rtio::RtioTcpAcceptor + Send>
})
};
let (addr, len) = addr_to_sockaddr(addr);
- let addrp = &addr as *_ as *libc::sockaddr;
+ let addrp = &addr as *const _ as *const libc::sockaddr;
let len = len as libc::socklen_t;
match unsafe { libc::bind(fd, addrp, len) } {
#[cfg(unix)] type msglen_t = libc::size_t;
impl rtio::RtioUdpSocket for UdpSocket {
- fn recvfrom(&mut self, buf: &mut [u8]) -> IoResult<(uint, rtio::SocketAddr)> {
+ fn recv_from(&mut self, buf: &mut [u8]) -> IoResult<(uint, rtio::SocketAddr)> {
let fd = self.fd();
let mut storage: libc::sockaddr_storage = unsafe { mem::zeroed() };
let storagep = &mut storage as *mut _ as *mut libc::sockaddr;
})
}
- fn sendto(&mut self, buf: &[u8], dst: rtio::SocketAddr) -> IoResult<()> {
+ fn send_to(&mut self, buf: &[u8], dst: rtio::SocketAddr) -> IoResult<()> {
let (dst, dstlen) = addr_to_sockaddr(dst);
- let dstp = &dst as *_ as *libc::sockaddr;
+ let dstp = &dst as *const _ as *const libc::sockaddr;
let dstlen = dstlen as libc::socklen_t;
let fd = self.fd();
let dolock = || self.lock_nonblocking();
- let dowrite = |nb, buf: *u8, len: uint| unsafe {
+ let dowrite = |nb, buf: *const u8, len: uint| unsafe {
let flags = if nb {c::MSG_DONTWAIT} else {0};
libc::sendto(fd,
- buf as *libc::c_void,
+ buf as *const libc::c_void,
len as msglen_t,
flags,
dstp,
buf: &[u8],
write_everything: bool,
lock: || -> T,
- write: |bool, *u8, uint| -> i64) -> IoResult<uint> {
+ write: |bool, *const u8, uint| -> i64) -> IoResult<uint> {
let mut ret = -1;
let mut written = 0;
if deadline == 0 {
}
// Also as with read(), we use MSG_DONTWAIT to guard ourselves
- // against unforseen circumstances.
+ // against unforeseen circumstances.
let _guard = lock();
let ptr = buf.slice_from(written).as_ptr();
let len = buf.len() - written;