WSock : WSAGetLastError / GetLastError returns 0

Discussion forum about all things Gupta, OpenText and the community.
Dave Rabelink
Founder/Site Admin
Founder/Site Admin
Netherlands
Posts: 3392
Joined: 24 Feb 2017, 09:12
Location: Gouda, The Netherlands

WSock : WSAGetLastError / GetLastError returns 0

Post by Dave Rabelink » 12 Aug 2009, 03:28

I'm playing around with WinSock lately and see that whatever error occurs on sock functions the WSAGetLastError always returns 0 (zero).
Searching in the old newsgroups I found a post indicating the WSAGetLastError calls GetLastError which is not usable in TD.

Does anyone have a workaround for this, so I can check the actual error code on WinSock failures ?
Regards,
Dave Rabelink

Image
Articles and information on Team Developer Tips & Tricks Wiki
Download samples, documents and resources from TD Sample Vault
Videos on TDWiki YouTube Channel

Dave Rabelink
Founder/Site Admin
Founder/Site Admin
Netherlands
Posts: 3392
Joined: 24 Feb 2017, 09:12
Location: Gouda, The Netherlands

Re: WSock : WSAGetLastError / GetLastError returns 0

Post by Dave Rabelink » 25 Aug 2009, 04:53

Seems the GetLastError in TD is an issue.

To be able to get the detailed errorcode using WinSock API functions, I created a small wrapper DLL which actually returns the WinSock error code when an error occurs.

I quickly created the VisualStudio project and added several WinSock functions. The wrapper dll can be used in TD versions < TD51.
Every API call has an extra receive parameter which holds the Winsock error. The wrapper dll calls WSAGetLastError internally and on errors passes the code back to TD.

More functions must be added, but it can be a nice start when you might need such a wrapper for your Winsock coding.

You can find the article and the download here :
https://wiki.tdcommunity.net/index.php/ ... ck_wrapper

(If you find this usable and you added more (or better all) WinSock functions, please post the VS project here so I can update the ZIP in the Sample Vault)
Regards,
Dave Rabelink

Image
Articles and information on Team Developer Tips & Tricks Wiki
Download samples, documents and resources from TD Sample Vault
Videos on TDWiki YouTube Channel

Return to “General Discussion”

Who is online

Users browsing this forum: [Ccbot] and 3 guests