I have made a dll which contain this function:

; LoadDll()
LoadDll PROC lpLoadInfo:DWORD
	invoke WSAStartup, 101h, ADDR ws_data
LoadDll ENDP
Then later in another function i have:

invoke socket, PF_INET, SOCK_DGRAM, NULL
and guess what, socket() fails with WSAEINVAL on W2K whilst on 95/98 and ME it works without a problem. Does ANYONE know why??
Posted on 2001-02-18 21:00:00 by Zynaps
Well I did this as a test :- WsaData WSADATA invoke WSAStartup,101h,addr WsaData ; startup WinSock invoke socket,AF_INET,SOCK_DGRAM,0 ; open a socket cmp eax,WSAEINVAL jne allok ret allok: and it was ok, give that a go. umbongo
Posted on 2001-02-20 11:11:00 by umbongo
That's because socket() itself does not return WSAEINVAL. It returns INVALID_SOCKET which means you should call WSAGetLastError (which returns WSAEINVAL) try:

    invoke WSAStartup,101h,addr WsaData
    invoke socket, AF_INET, SOCK_DGRAM, 0
        invoke WSAGetLastError
Then tell me if it still works...
Posted on 2001-02-20 12:14:00 by Zynaps
hmm... yeah, sorry I wasn't thinking, this is what happens when you stop writing a device driver for 10 seconds and reply to a message board..... My only suggestion now is have a look at the samples, I have an assemly version of telnet on my machine I can send it to you if you like. umbongo
Posted on 2001-02-20 12:32:00 by umbongo
All my TCP/IP stuff works on W2K, it's just the UDP/IP i have problems with. But i have yet to test my latest version so it might be fixed. I dissasembled a program i know uses UDP and that i know works on W2K, and the socket call is exactly the same as mine. Also the WSAStartup call was the same. It might have had something to do with me having the two calls in different dll functions. We'll see...
Posted on 2001-02-20 17:28:00 by Zynaps
Having the call in different DLLs might be the problem, I'd keep your WSAStartup and socket calls together. If you have a function called OpenSocket and CloseSocket, one can call WSAStartup the other WSAShutdown(?) I know they are reference counted so calling it more than once doesn't matter. Just as long as the calls are matched. To be honest, I don't think the WSAShutdown calls matter, Windows will do it for you if you do not bother it's just good practice to do it. umbongo
Posted on 2001-02-21 04:40:00 by umbongo
I found out what the problem is (sort of), but i don't think it's fixable. The dll i wrote is written to be called by mIRC's $dll() identifier. On Win95/98/ME it still works if i remove the WSAStarup/WSACleanup calls from the dll, because apparently it is OK if the calling process has already issued them. On Win2k it doesn't work if i have them in or not. So my conclusion is that it is either a mIRC or Win2k issue that i can't fix. My bet is on Win2k. As a test i wrote a simple .exe that opens an UDP socket and it ran without a problem on Win2k so now im gonna write a program that calls my dll (instead of having mIRC to call it) and see if still works.
Posted on 2001-02-24 08:21:00 by Zynaps