native: Remove unused and untested UnixDatagram
This commit is contained in:
parent
b55394415a
commit
67ee480936
@ -155,77 +155,6 @@ impl rtio::RtioPipe for UnixStream {
|
||||
}
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// Unix Datagram
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
pub struct UnixDatagram {
|
||||
inner: UnsafeArc<Inner>,
|
||||
}
|
||||
|
||||
impl UnixDatagram {
|
||||
pub fn connect(addr: &CString) -> IoResult<UnixDatagram> {
|
||||
connect(addr, libc::SOCK_DGRAM).map(|inner| {
|
||||
UnixDatagram { inner: UnsafeArc::new(inner) }
|
||||
})
|
||||
}
|
||||
|
||||
pub fn bind(addr: &CString) -> IoResult<UnixDatagram> {
|
||||
bind(addr, libc::SOCK_DGRAM).map(|inner| {
|
||||
UnixDatagram { inner: UnsafeArc::new(inner) }
|
||||
})
|
||||
}
|
||||
|
||||
fn fd(&self) -> fd_t { unsafe { (*self.inner.get()).fd } }
|
||||
|
||||
pub fn recvfrom(&mut self, buf: &mut [u8]) -> IoResult<(uint, CString)> {
|
||||
let mut storage: libc::sockaddr_storage = unsafe { intrinsics::init() };
|
||||
let storagep = &mut storage as *mut libc::sockaddr_storage;
|
||||
let mut addrlen: libc::socklen_t =
|
||||
mem::size_of::<libc::sockaddr_storage>() as libc::socklen_t;
|
||||
let ret = retry(|| unsafe {
|
||||
libc::recvfrom(self.fd(),
|
||||
buf.as_ptr() as *mut libc::c_void,
|
||||
buf.len() as libc::size_t,
|
||||
0,
|
||||
storagep as *mut libc::sockaddr,
|
||||
&mut addrlen) as libc::c_int
|
||||
});
|
||||
if ret < 0 { return Err(super::last_error()) }
|
||||
sockaddr_to_unix(&storage, addrlen as uint).and_then(|addr| {
|
||||
Ok((ret as uint, addr))
|
||||
})
|
||||
}
|
||||
|
||||
pub fn sendto(&mut self, buf: &[u8], dst: &CString) -> IoResult<()> {
|
||||
let (dst, len) = try!(addr_to_sockaddr_un(dst));
|
||||
let dstp = &dst as *libc::sockaddr_storage;
|
||||
let ret = retry(|| unsafe {
|
||||
libc::sendto(self.fd(),
|
||||
buf.as_ptr() as *libc::c_void,
|
||||
buf.len() as libc::size_t,
|
||||
0,
|
||||
dstp as *libc::sockaddr,
|
||||
len as libc::socklen_t) as libc::c_int
|
||||
});
|
||||
match ret {
|
||||
-1 => Err(super::last_error()),
|
||||
n if n as uint != buf.len() => {
|
||||
Err(io::IoError {
|
||||
kind: io::OtherIoError,
|
||||
desc: "couldn't send entire packet at once",
|
||||
detail: None,
|
||||
})
|
||||
}
|
||||
_ => Ok(())
|
||||
}
|
||||
}
|
||||
|
||||
pub fn clone(&mut self) -> UnixDatagram {
|
||||
UnixDatagram { inner: self.inner.clone() }
|
||||
}
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// Unix Listener
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
Loading…
x
Reference in New Issue
Block a user