Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / fpc-pascal / 2008-02

WSAGetLastError returns 0 when it shouldn't but I cannot see why

3 messages · 2 people ·

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Luca Olivetti

Hello, before reporting a bug, I'm asking for support here since I'm not sure I doing something wrong (and if so what am I doing wrong).

While using synapse in a thread, I saw that it didn't report an error on connection, eventually I saw that the call to WSAGetLastError was returning 0 even if it couldn't connect and the connect call returned an error.
I found bug 10205 (http://bugs.freepascal.org/view.php?id=10205) but in my case there is no direct writeln in sight (side note: why isn't it possible to add a note to a closed bug?).

Oddly enough, a slightly modified threadwsagetlast (attached as project3.lpr) from the one in the bug report works as expected, while my thread (now using directly the sockets unit, not wrapped by synapse) still reports 0.

The attached project2.lpr has a connection to a non existent host/port in a thread and outside the thread, and it both cases it reports 0 (UseSynchronize true or false doesn't make a difference), and while reduced to the minimum it has the same structure of the thread I'm actually going to use.
project3.lpr is adapted from the bug report and correctly reports 10060 (connection timed out), but I cannot really see the difference between one and the other (besides the fact that mine uses methods and the other uses procedures defined outside the class, but that shouldn't really matter, should it?)
Note that project3 uses deprecated sockets procedures, while mine uses the "correc" fp prefixed ones, but I tried with the deprecated ones before with the same result.

This is under windows with fpc 2.2.0 (coming from a lazarus snapshot), the original problem with synapse was with a lazarus snapshot with 2.2.1 (hence I went back to 2.2.0 to see if it was a regression in 2.2.1).

Bye

Luca
Marco van de Voort
to Luca Olivetti
Hello, before reporting a bug, I'm asking for support here since I'm not sure I doing something wrong (and if so what am I doing wrong).

I can't test easily atm, but trying killing off socketerror and the older calls without fp. Try also to move the "write (thread created)" after the sleep.

Luca Olivetti
to Marco van de Voort

En/na Marco van de Voort ha escrit:

Show quoted text 6 lines
> Hello, before reporting a bug, I'm asking for support here since I'm not > sure I doing something wrong (and if so what am I doing wrong). I can't test easily atm, but trying killing off socketerror and the older calls without fp. Try also to move the "write (thread created)" after the sleep.

Your remarks are about the working example (project3). The non working one already uses the fp calls, but it still uses SocketError (what should be its replacement? anyway I saw that it just wraps WSAGetLastError).

Bye

Luca