Prev: Printing the Form
Next: Common Controls 5.0 / Windows 7
From: Tony Toews [MVP] on 11 Nov 2009 01:27 "Nobody" <nobody(a)nobody.com> wrote: >> However I still didn't need to Start Sock. > >You must. Maybe the OS you are using is forgiving, but it may not work in >other OS'es or service packs. Quote from the first paragraph of WSAStartup's >remarks section: "The WSAStartup function must be the first Windows Sockets >function called by an application or DLL. It allows an application or DLL to >specify the version of Windows Sockets required and retrieve details of the >specific Windows Sockets implementation. The application or DLL can only >issue further Windows Sockets functions after successfully calling >WSAStartup." > >If you don't call it, you would normally get WSANOTINITIALISED, but it seems >that the OS that you are using calls it for you, but this may not happen in >the future. This is with Windows XP. And it was a clean install of Windows XP with the only software installed on it being an antivirus. I would agree that this isn't a good way of doing things. I mentioned this more as an additional clue as to figure out just what the heck is going on. Tony -- Tony Toews, Microsoft Access MVP Tony's Main MS Access pages - http://www.granite.ab.ca/accsmstr.htm Tony's Microsoft Access Blog - http://msmvps.com/blogs/access/ For a free, convenient utility to keep your users FEs and other files updated see http://www.autofeupdater.com/ Granite Fleet Manager http://www.granitefleet.com/
From: Nobody on 11 Nov 2009 01:29 "Nobody" <nobody(a)nobody.com> wrote in message news:OY8n7apYKHA.3712(a)TK2MSFTNGP06.phx.gbl... > "Tony Toews [MVP]" <ttoews(a)telusplanet.net> wrote in message > news:d87kf5l851h3gk602mfl6it06svu8bv6c2(a)4ax.com... >> However I still didn't need to Start Sock. > > You must. Maybe the OS you are using is forgiving, but it may not work in > other OS'es or service packs. Quote from the first paragraph of > WSAStartup's remarks section: "The WSAStartup function must be the first > Windows Sockets function called by an application or DLL. It allows an > application or DLL to specify the version of Windows Sockets required and > retrieve details of the specific Windows Sockets implementation. The > application or DLL can only issue further Windows Sockets functions after > successfully calling WSAStartup." > > If you don't call it, you would normally get WSANOTINITIALISED, but it > seems that the OS that you are using calls it for you, but this may not > happen in the future. I just tried the sample without using WSAStartup, and get this error on XP+SP2, VB6+SP5: Winsock error - Failed to create socket. Error number:10093 It works fine if I call it first, by clicking on "Start sock" button.
From: Nobody on 11 Nov 2009 01:40 "Tony Toews [MVP]" <ttoews(a)telusplanet.net> wrote in message news:60kkf5llnaorkkb91hcj9a5t6fuii6g820(a)4ax.com... > LNum: 7563 > LNum: 0 > LNum: -1 > LNum: -1 > LNum: -1 > LNum: -1 > LNum: -1 > LNum: -1 > LNum: -1 > > When I download a 106 Kb file I get 6 or so more of the LNum: 8192 > lines and 6 or so more of the Lnum -1 lines. So I don't know why > the T1_MouseUp routine is being called again like that resulting in > multiple -1 entries on LNum. With 2 MB file, I don't get 0 or -1, and get status code 200. If it's -1, you need to call WSAGetLastError() immediately after WReceive, which is an alias for recv() function. Private Declare Function WSAGetLastError Lib "ws2_32.dll" () As Long If LNum = -1 Then Debug.Print "recv returned -1, WSAGetLastError = " & WSAGetLastError() End If
From: mayayana on 11 Nov 2009 09:59 > > I have TCP/IP V6 also enabled in Win XP. Maybe that's a difference. > I don't know what role that might have, but I wouldn't think it matters, since it relates to IP addresses. The repeated -1 doesn't seem so surprising, though, given that you never initialized winsock. When the download is finished the sub DisConnect is called, which calls the winsock function WCloseSocket (closesocket). But you never opened a socket, so there's no handle for a socket to close. All of that seems to make sense, except for the question of how you're managing to contact the server without initializing winsock. I'm still unclear whether you've tried initializing winsock, and what happens then. It should work properly because the variable HSock will contain a handle for that particular session and close the connection appropriately. > Given that this control has something to do with a Mouse maybe it's > because it's a laptop with a Mouse pad and an external USB mouse. I > unplugged the USB mouse but that didn't make a difference. > That doesn't matter. The MouseUp message was just a trick that I came across that seemed like a good idea. The call to WSAAsyncSelect sets up the callback for data arrival. It requires an hWnd and a message number. The textbox is not visible, so it gets no actual mouse messages. By assiging the textbox hWnd and the MouseUp message for the callback, VB can be enlisted to handle the callback. That avoids needing to subclass the UC or something else with an hWnd. The message code can be anything. It's just MouseUp because that's built in. If I assigned a new code like: Const DATA_ARRIVAL = WM_USER + 100 then again there would have to be a subclass because that message won't come through. (I assume the form message loop will never forward it to begin with, but even if it did, there's no way to assign a sub for the undefined textbox event of "DataArrival".)
From: Tony Toews [MVP] on 11 Nov 2009 14:11
"mayayana" <mayaXXyana(a)rcXXn.com> wrote: > I'm still unclear whether you've tried initializing >winsock, and what happens then. It should work >properly because the variable HSock will contain >a handle for that particular session and close the >connection appropriately. I've tried that in the past as well as today and no difference in behavior. I still get the repeated -1s. Tony -- Tony Toews, Microsoft Access MVP Tony's Main MS Access pages - http://www.granite.ab.ca/accsmstr.htm Tony's Microsoft Access Blog - http://msmvps.com/blogs/access/ For a free, convenient utility to keep your users FEs and other files updated see http://www.autofeupdater.com/ Granite Fleet Manager http://www.granitefleet.com/ |