문제

Is there any way to perform 3-way TCP/IP handshake in Ada without the use of c++ Pragma?

If so, does anybody have an example?

도움이 되었습니까?

해결책

If you’re using GNAT, the answer is to use GNAT.Sockets; from the spec of that package, there’s the server side (with use GNAT.Sockets):

Address.Addr := Addresses (Get_Host_By_Name (Host_Name), 1);
Address.Port := 5876;
Create_Socket (Server);
Set_Socket_Option
  (Server,
   Socket_Level,
   (Reuse_Address, True));
Bind_Socket (Server, Address);
Listen_Socket (Server);
Accept_Socket (Server, Socket, Address);

and the client side:

Address.Addr := Addresses (Get_Host_By_Name (Host_Name), 1);
Address.Port := 5876;
Create_Socket (Socket);
Set_Socket_Option
  (Socket,
   Socket_Level,
   (Reuse_Address, True));
Connect_Socket (Socket, Address);

If you’re not using GNAT, you may be lucky enough to find that your compiler provides an equivalent. If you’re using GNAT but want to see how they’ve done it, look at the body of GNAT.Sockets.

다른 팁

If you want to control the sending of SYN, SYN-ACK and ACK packages youself, you have to circumvent the TCP stack, as that is what a TCP stack does for you, so you don't have to do it yourself.

How to circumvent the TCP stack depends on your operating system.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top