Compare commits
3 Commits
2af591489a
...
a1971693ef
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
a1971693ef | ||
|
|
28b29d3dbf | ||
|
|
77f441dea4 |
@@ -105,7 +105,7 @@ fn gen_tcp_connect(
|
|||||||
) -> Result(Socket, Reason)
|
) -> Result(Socket, Reason)
|
||||||
|
|
||||||
// https://www.erlang.org/doc/apps/kernel/gen_tcp.html#send/2
|
// https://www.erlang.org/doc/apps/kernel/gen_tcp.html#send/2
|
||||||
@external(erlang, "ipc_ffi", "send")
|
@external(erlang, "tcp_ffi", "send")
|
||||||
fn gen_tcp_send(socket: Socket, packet: BitArray) -> Result(Nil, Reason)
|
fn gen_tcp_send(socket: Socket, packet: BitArray) -> Result(Nil, Reason)
|
||||||
|
|
||||||
// https://www.erlang.org/doc/apps/kernel/gen_tcp.html#close/1
|
// https://www.erlang.org/doc/apps/kernel/gen_tcp.html#close/1
|
||||||
@@ -113,5 +113,5 @@ fn gen_tcp_send(socket: Socket, packet: BitArray) -> Result(Nil, Reason)
|
|||||||
fn gen_tcp_close(socket: Socket) -> Nil
|
fn gen_tcp_close(socket: Socket) -> Nil
|
||||||
|
|
||||||
// https://www.erlang.org/doc/apps/kernel/gen_tcp.html#shutdown/2
|
// https://www.erlang.org/doc/apps/kernel/gen_tcp.html#shutdown/2
|
||||||
@external(erlang, "gen_tcp", "shutdown")
|
@external(erlang, "tcp_ffi", "shutdown")
|
||||||
fn gen_tcp_shutdown(socket: Socket, how: atom.Atom) -> Result(Nil, Reason)
|
fn gen_tcp_shutdown(socket: Socket, how: atom.Atom) -> Result(Nil, Reason)
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ pub fn main() -> Nil {
|
|||||||
gleeunit.main()
|
gleeunit.main()
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn foo_test() {
|
pub fn tcp_send_shutdown_receive_test() {
|
||||||
let socket_path = "/tmp/musicplayer-test.sock"
|
let socket_path = "/tmp/musicplayer-test.sock"
|
||||||
|
|
||||||
let assert Ok(_) = echo_server.new(socket_path)
|
let assert Ok(_) = echo_server.new(socket_path)
|
||||||
@@ -20,15 +20,7 @@ pub fn foo_test() {
|
|||||||
let assert Ok(_) = tcp.send(socket, message)
|
let assert Ok(_) = tcp.send(socket, message)
|
||||||
})
|
})
|
||||||
|
|
||||||
// TODO not valid syntax?
|
let assert Ok(_) = tcp.shutdown(socket)
|
||||||
// let assert Ok(Nil) = tcp.shutdown(socket)
|
|
||||||
//
|
|
||||||
// test: musicplayer_test.foo_test
|
|
||||||
// code: let assert Ok(Nil) = tcp.shutdown(socket)
|
|
||||||
// value: Ok
|
|
||||||
// info: Pattern match failed, no pattern matched the value.
|
|
||||||
|
|
||||||
let _ = tcp.shutdown(socket)
|
|
||||||
|
|
||||||
let timeout_ms = 100
|
let timeout_ms = 100
|
||||||
assert Ok("hello, world!\n") == tcp.receive(socket, timeout_ms)
|
assert Ok("hello, world!\n") == tcp.receive(socket, timeout_ms)
|
||||||
|
|||||||
Reference in New Issue
Block a user