你好,游客 登录 注册 搜索
背景:
阅读新闻

AdaSockets 1.8.11 发布

[日期:2013-08-05] 来源:oschina.net  作者:Linux [字体:大 中 小]

AdaSockets 1.8.11 发布,该版本使用合适的编译器来编译 C 常量文件。

AdaSockets 是一个 Ada 95 的 socket 编程开发包,支持单播和多播套接字,使用面向对象结构来简化套接字操作。

示例代码:

with Ada.Command_Line; use Ada.Command_Line;
with Ada.Exceptions; use Ada.Exceptions;
with Ada.Text_IO; use Ada.Text_IO;
with Sockets.Stream_IO; use Sockets, Sockets.Stream_IO;

procedure Stream_Sender is

  -- Usage: stream_sender remotehost remoteport
  -- Example: stream_sender localhost 5000

  Outgoing_Socket : Socket_FD;
  Stream : aliased Socket_Stream_Type;
  Line : String (1 .. 200);
  Last : Natural;

begin
  if Argument_Count /= 2 then
      Raise_Exception
        (Constraint_Error'Identity,
        "Usage: " & Command_Name & " remotehost remoteport");
  end if;

  Socket (Outgoing_Socket, PF_INET, SOCK_STREAM);
  Connect (Outgoing_Socket, Argument (1), Positive'Value (Argument (2)));
  Initialize (Stream, Outgoing_Socket);

  loop
      Put ("Type a string> ");
      Flush;
      Get_Line (Line, Last);
      String'Output (Stream'Access, Line (Line'First .. Last));
  end loop;

exception
  when End_Error => null;
end Stream_Sender;

AdaSockets 的下载地址:请点这里

linux
相关资讯       AdaSockets 1.8.11  AdaSockets 
本文评论   查看全部评论 (0)
表情: 表情 姓名: 字数

       

评论声明
  • 尊重网上道德,遵守中华人民共和国的各项有关法律法规
  • 承担一切因您的行为而直接或间接导致的民事或刑事法律责任
  • 本站管理人员有权保留或删除其管辖留言中的任意内容
  • 本站有权在网站内转载或引用您的评论
  • 参与本评论即表明您已经阅读并接受上述条款