以下
let new_socket () = Lwt_unix.socket Unix.PF_INET Unix.SOCK_STREAM 0 in
let socket_address = Network.make_address "127.0.0.1" 7777 in
let listening_socket = new_socket () in
Lwt_unix.setsockopt listening_socket Unix.SO_REUSEADDR true;
Lwt_unix.bind listening_socket socket_address;
导致此错误:
错误:正确性:2:remote_client:0:设置
Unix.Unix_error(Unix.EADDRINUSE, "bind", "")
Raised at file "src/core/lwt.ml", line 782, characters 22-23
Called from file "src/unix/lwt_main.ml", line 34, characters 8-18
Called from file "src/oUnit.ml", line 597, characters 6-10`
最后一行未能授予绑定,想法原因,如何通过?
答案 0 :(得分:3)
错误已明确说明:您尝试绑定的地址已在使用中,套接字已绑定在端口7777上。
要了解函数的Unix_error
代码,请查看相应C unix函数的手册,在这种情况下bind(2)。