@bnl: "Hello all!
A couple of weeks I sent the mail below, but got no answers. Well,=20
I then tried to use gnat 3.4.2 from minGW, instead of 3.15.p, but I got he=
=20
same results still. Besides, it it only me that misses libaddr2line, used t=
o=20
print stacktraces? It was included in 3.15p, but now I cant find it :(
Below is the last mail, and the sample code. Any pointers to what is happen=
ing=20
are very appreciated.=20
/Bj=F6rn
I'm writing a console socket application, with several tasks, and I run into
som strange behaviour when tasks are involved. Below is output from a test
program (also below). The first output is when the tasking part was comment
ed out, the second output is from when tasking is part of the program. comp=
ile
d with gnat 3.15p on a w2k box. (just gnatmake socket_connect.adb)
What I wonder is why I can get the correct errorcode by calling=20
WSAGetLasterror (which is what Gnat.Sockets.Thin.Socket Errno does, just=20
pragma import) when having no tasks, but not when having tasks.
It gets even more strange (to me at least) when i realize that the associat
ed error string to the exception has the correct error code in both cases.
By looking in the sources I see, that gnat is using=20
Gnat.Sockets.Thin.Socket Errno to create that error-string.=20
Testing with Object Ada 7.2.2 (well basically the same) will get the=20
correct errorcode no matter of tasking or not
regards
Bj=F6n Lundin
Without tasking
=2D-
Startup sockets
Get a socket
Try to connect!
GNAT.SOCKETS.SOCKET ERROR: [10061] Connection refused
 10061 - Connection refused
Resolve Exception - CONNECTION REFUSED
With tasking
=2D-
Task running, Execute!
Startup sockets
Get a socket
Try to connect!
GNAT.SOCKETS.SOCKET ERROR: [10061] Connection refused
 0 - Unknown system error
Resolve Exception - CONNECTION REFUSED
=2D
=2D-
with Text Io;
with Gnat.Sockets;
with Gnat.Sockets.Thin;
with Ada.Exceptions;
procedure Socket Connect is
  Socket   : Gnat.Sockets.Socket Type;
  Address  : Gnat.Sockets.Sock Addr Type;
  Error    : Integer :=3D 0;
  task type Run Once is
    entry Execute;
  end Run Once;
  task body Run Once is
  begin
    select
      accept Execute do
        text io.put line("Task running, Execute!");
      end Execute;
    or
      terminate;
    end select;
  end Run Once;
begin
  declare
    TmpTask : Run Once;
  begin
    TmpTask.Execute;
  end;
  text io.put line("Startup sockets");
  Gnat.Sockets.Initialize;
  text io.put line("Get a socket");
  Gnat.Sockets.Create Socket (Socket);
  text io.put line("Try to connect!");
  Address.Addr :=3D Gnat.Sockets.Inet Addr("83.161.120.155");=20
  Address.Port :=3D 8000;
  Gnat.Sockets.Connect Socket (Socket, Address);
  text io.put line("Connected!");
  text io.put line("Close socket!");
  Gnat.Sockets.Close Socket (Socket);
  text io.put line("Shutdown sockets!");
  Gnat.Sockets.Finalize;
  text io.put line("Done!");
exception
  when E: others =3D>
   Text IO.Put Line(Ada.Exceptions.Exception Name (E) & ": " &=20
                    Ada.Exceptions.Exception Message (E));
  =20
   Error :=3D Gnat.Sockets.Thin.Socket Errno;
   Text IO.Put Line(Integer'Image(Error) & " - " &=20
            Gnat.Sockets.Thin.Socket Error Message (Error));
=20
   Text IO.Put Line("Resolve Exception" & " - " &=20
     Gnat.Sockets.Error Type'Image(Gnat.Sockets.Resolve Exception(E)));
   Gnat.Sockets.Finalize;
end socket connect;
=2D
=2D-"
    @tmoran: "<quote>
  Are you sure of that?  The docs I have, and relied on, say
"Note that errors are thread-specific".  If that's not true, then
it's pure luck if a multi-thread socket app manages to work.
Good luck is not something I normally base a design on."
    @jcreem: ""Bj�rn Lundin" <email_address> wrote in message 
news:<email_address>
Hello all!
A couple of weeks I sent the mail below, but got no answers. Well,
I then tried to use gnat 3.4.2 from minGW, instead of 3.15.p, but I got he
same results still. Besides, it it only me that misses libaddr2line, used to
print stacktraces? It was included in 3.15p, but now I cant find it :(
Looks to me like this function returns a thread specific value so it should 
be ok.
Clearly it is not ok for some reason. I'd guess something about the 
exception propagation within
the threaded run-time support is clearing that error value. I see no reason 
why it should
I recommend you submit a bugzilla bug at the gcc site. At the very least 
this should be documented."
    @research: "...
<quote>
...
A "libaddr2line.a" file for Windows is here:
<url>
12.2 KB. Contains: "libaddr2line.a" (13,086 bytes).
The same file was once at Sourceforge and it is not there now:
  <url>
."
    @nospam: "If this is the file which was on sourceforge with an older version of 
binutils, it doesn't work with current binutils-2.15.91-20040904-1
Link will be fine, but output of stacktrace will be corrupted.
You have to build libaddr2line.a with corresponding binutils version (check 
binutils makefile)
"Craig Carey" <email_address> a �crit dans le message de news: 
<email_address>
<quote>"
    @bnl: "m=E5ndag 17 januari 2005 23:04 skrev Randy Brukardt:
<quote>
Hmm, not according to:
<<url>
/winsock/wsagetlasterror_2.asp>
In short from the webpage:
Return Values
The return value indicates the error code for this thread's last Windows=20
Sockets operation that failed.
Remarks
The WSAGetLastError function returns returns the last error that occurred f=
or=20
the calling thread.=20
So Microsoft thinks it's thread/task safe and it is if I use Object Ada. No=
w,=20
I'm (my company) is moving from Object Ada to Gnat, but this one is a=20
showstopper :( (We already did the transition on Aix, and I like gnat more=
=20
than OA)
Nicolas explained to me that what I want will not work with 3.15 or with=20
3.4.2 :( but the explanation of libaddress2line was good news.=20
I dont' use gnat.sockets directly, I use a 10 year old homemade interface,=
=20
that works with other compilers and operating systems, and won't break lega=
cy=20
code in production on several sites.=20
The sample I sent was to illustrate my problem with known 'standardcode'
/Bj=F6rn"
{'source': 'USENET', 'other_information': '{"reply_count": 5, "forum_name": "comp.lang.ada.20140710.mbox"}', 'file': 'data/output/usenet-comp.lang.parquet'}