Connect_Socket(Socket, Address, Timeout => 2.0, Status => status);
Put_Line("Selector " & Selector_Status'Image(status));
不起作用,程序在该位置挂起。如果您将超时设置为1秒,它将起作用。如何使延迟更多?
Set_Socket_Option (Socket, Option => (Name => Receive_Timeout, > Timeout => 1.0));
Set_Socket_Option (Socket, Option => (Name => > Send_Timeout, Timeout => 1.0));
此外,延迟不起作用,程序挂起。读取操作不良 连接和关闭连接
测试过程:
procedure start_client is Address : Sock_Addr_Type; Socket : Socket_Type; pck : pck_ptr; thred_r : client_r; thred_w : client_w; last : integer; status : Selector_Status; begin pck := new packet_srv; Address.Addr := Addresses (Get_Host_By_Name ("127.0.0.1"), 1); Address.Port := 5910; Create_Socket (Socket); Connect_Socket (Socket, Address, Timeout => 1.0, Status => status); Put_Line("Selector " & Selector_Status'Image(status)); if status /= completed then return; end if; thread_data.add_sock(socket); thred_r.Start; thred_w.Start; loop Get_Line (pck.str, last); pck.len := last; pck.id := 0; thred_w.send_data(pck.all); exit when pck.str(1..4) = "exit"; end loop; Close_Socket(Socket); end start_client;