Log in

View Full Version : Newbie's Q. about Winsock detail


O. Visidor
May 25th, 2002, 15:55
Hi Reversers !

Well, trying to learn a bit about socket programming here.
Could a Win32/Winsock/Wininet guru could give me a hint ?

- Is zero (0) ever assigned as a (per process) socket handle ?
-Wwhat are the specified/practical effects of a call to recv ( resp. send ) using a number which is not (or not yet) an assigned socket handle number for this process ? Is the call supposed to return an error, or does it try to send ( receive) blindly, to a non existent socket ?
- If the answer to either question dependent on the Win32 / Winsock/ Wsock2/ implementations ? How ?

Another question : are the Wininet.dll functions documented and where can I find that doc ?


TIA
--
O.V.

foxthree
May 25th, 2002, 19:41
First, let me answer your questions:

(1) I don't think so. Sockets are always non-zero numbers as far as I've seen
(2) If you attempt to send data via a socket that is not recognized by the system, you're sure to get the error ("Attempting to perform an operation on something that is not a socket" or something similar)

Windows Sockets has always been a "schizophrenic" implementation of the Sockets specification. Microsoft has never really implemented the *complete*sockect specficiation until Win2K or later. So, if the above questions are what I guess, "true" raw socket support is available only on systems >= Win2K (not even NT). [Yes, Winsock 2.0 provides raw sockets by only for ICMP]

There are a couple of libraries that allow you to do "raw" sockets under other Win* platforms.

Also, WinINET APIs are completely documented in MSDN. Look for it

If you need any further information, drop a line.

Signed,
-- FoxThree

O. Visidor
May 27th, 2002, 11:28
Thanks for the cool answer, FoxThree !

Nope, I was not investigating in "raw sockets". The rationale behind my questions was, trying to find out why the "tini.exe" miniserver app (who said: trojan ? by A. Vidstrom works well on my win 98 B but crashes the Win 95 B box (with winsock 2 and other updates) .

A quick look at a disassembly showed it is a simple 3-threaded server that unfortunately takes zero step to check for winsock ( or other ) errors ( and also does not care to clean behind itself ...) Well maybe the real wonder is it DOES seem to work under Win 98 ( and NT + ? ) but under Win 95 it fails, and I thought it might be because it starts its sending/receiving threads without waiting for a connection established or confirmed, thus using that invalid socket "zero". Just a guess from dead listing however.
I wondered if the Winsock2 for 95 could behave different from its 98 counterpart.

thanks again, I'll do a search for that Wininet material some other day too.

--
O. V.