mirror of
https://github.com/saymrwulf/xous-core.git
synced 2026-11-20 09:03:28 +00:00
make the UDP socket specifiable on command line
this makes the bindings work on things other than localhost
This commit is contained in:
parent
760957154e
commit
271fd4d559
1 changed files with 5 additions and 5 deletions
|
|
@ -212,13 +212,13 @@ impl<'a> ShellCmdApi<'a> for NetCmd {
|
||||||
if let Some(udp_socket) = &self.udp {
|
if let Some(udp_socket) = &self.udp {
|
||||||
write!(ret, "Socket listener already installed on {:?}.", udp_socket.socket_addr().unwrap()).unwrap();
|
write!(ret, "Socket listener already installed on {:?}.", udp_socket.socket_addr().unwrap()).unwrap();
|
||||||
} else {
|
} else {
|
||||||
let port = if let Some(tok_str) = tokens.next() {
|
let socket = if let Some(tok_str) = tokens.next() {
|
||||||
if let Ok(n) = tok_str.parse::<u16>() { n } else { 6502 }
|
tok_str
|
||||||
} else {
|
} else {
|
||||||
6502
|
"127.0.0.1:6502"
|
||||||
};
|
};
|
||||||
let mut udp = net::UdpSocket::bind_xous(
|
let mut udp = net::UdpSocket::bind_xous(
|
||||||
format!("127.0.0.1:{}", port),
|
socket,
|
||||||
Some(UDP_TEST_SIZE as u16)
|
Some(UDP_TEST_SIZE as u16)
|
||||||
).unwrap();
|
).unwrap();
|
||||||
udp.set_read_timeout(Some(Duration::from_millis(1000))).unwrap();
|
udp.set_read_timeout(Some(Duration::from_millis(1000))).unwrap();
|
||||||
|
|
@ -228,7 +228,7 @@ impl<'a> ShellCmdApi<'a> for NetCmd {
|
||||||
[Some(NetCmdDispatch::UdpTest1.to_usize().unwrap()), None, None, None]
|
[Some(NetCmdDispatch::UdpTest1.to_usize().unwrap()), None, None, None]
|
||||||
);
|
);
|
||||||
self.udp = Some(udp);
|
self.udp = Some(udp);
|
||||||
write!(ret, "Created UDP socket listener on port {}", port).unwrap();
|
write!(ret, "Created UDP socket listener on socket {}", socket).unwrap();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
"udpclose" => {
|
"udpclose" => {
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue