comp.lang.ada
 help / color / mirror / Atom feed
From: Sven Nilsson <emwsvni@emw.ericsson.se>
Subject: Re: Sockets and NT
Date: Tue, 06 Mar 2001 08:47:56 +0100
Date: 2001-03-06T08:47:56+01:00	[thread overview]
Message-ID: <3AA4962C.DBDE27C1@emw.ericsson.se> (raw)
In-Reply-To: 200136-0051-32781@foorum.com

Hi

We're using a socket to send data from an Ada 95 application to a Delphi
test-tool. When we implemented this some years ago we found that the
best way was to implement the socket-specific things in C on the windows
platform and then use standard Ada to C imports. Something like this
(please note the code is part of a larger program, so it might not be
complete):

// init_socket.c -------------------------------------------------
#include <winbase.h>
#include <winadvapi.h>
#include <winnt.h>
#include <windows.h>
#include <Windows32/sockets.h>
#include <stdlib.h>
#include <stdio.h>
#include <fcntl.h>
#include <strings.h>
#include <errno.h>

int create_socket()
{
  int sock;

  sock = socket(AF_INET, SOCK_STREAM, 0);
  return sock;
}

// End C code ------------------------------------------------

-- Ada socket thingy -----------------------------------------
with Ada.Text_IO;

procedure Win_Sock is
   -- Link with compiled init_socket.c
   pragma Linker_Options("init_socket.o");

   -- Import socket library calls.
   function create_socket() return Integer;
   pragma Import(Stdcall, Create_Socket, "create_socket");

   Sock : integer := 0;
begin
   Sock := create_socket();

   Ada.Text_IO.Put_Line("Created socket no "&
                        Integer'image(Sock));
end Win_Sock;

-- End of ADA program ------------------------------

This seems to do the trick for us. Mind you,  WinSock really sucks so it
might not be the best of solutions...

-Sven

Jacques Croizat wrote:
> 
> Hello,
> I Want to use socket communication in
> Ada programs.
> I had a look into
> http://www.adapower.com and I found
> good materials from
> http://www-inf.enst.fr/ANC/ that work fine
> in a Unix platform.
> Now I want to make it work with Windows
> NT. I succeeded in producing an
> executable for NT but the execution fails: I
> cannot create a socket.
> Thank you for any help.
> 
> __________________________________________________________
> Ce message a �t� post� via la plateforme Web club-Internet.fr
> This message has been posted by the Web platform club-Internet.fr
> 
> http://forums.club-internet.fr/



  reply	other threads:[~2001-03-06  7:47 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2001-03-06  7:27 Sockets and NT Jacques Croizat
2001-03-06  7:47 ` Sven Nilsson [this message]
2001-03-06 14:52 ` Marin David Condic
2001-03-07 21:50   ` Robert A Duff
2001-03-07 22:36     ` Marin David Condic
2001-03-08 11:38     ` John English
2001-03-06 14:59 ` Ted Dennison
2001-03-06 20:23 ` Randy Brukardt
2001-03-09  5:51 ` DuckE
2001-03-09 15:14   ` Marin David Condic
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox