[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

microsoft.public.vb.general.discussion

Re: Reliable Winsock Control alternative

(nobody)

9/13/2011 3:02:00 PM

"Nobody" <nobody@nobody.com> wrote in message news:...
> "Michel Posseth [MCP]" <msdn@posseth.com> wrote in message
> news:OOeAm34vJHA.5584@TK2MSFTNGP04.phx.gbl...
>> Hello Nobody
>>
>>
>> You could use the form with the winsock control just as anny other class
>> in the Activex executable , you can even create it late bound
>>
>> you can also just use the diverse coding solutions like this one ( wich
>> is AFAIK one of the best outta there )
>> http://www.a1vbcode.com/ap...
>> http://www.planet-source-code.com/vb/scripts/ShowCode.asp?txtCodeId=52072&am...
>>
>> And free
>
> These are based on CSocket. One thing that I didn't mention earlier is
> that sockets created with CSocket are non-blocking sockets. This happens
> when WSAAsyncSelect() is called(according to the remarks section in MSDN),
> which what CSocket is doing during initialization. This means that the
> call to "sendto" should not block, and if there is a reason that it would
> block, it should return immediately with error WSAEWOULDBLOCK. That's not
> what I saw. "sendto" blocked for a long period before returning. This
> seems to be a bug in the OS. WSAStartup() was called with &H101, meaning
> version 1.1 in this case. I changed that to 2.0, but I forgot if that made
> any difference. I don't have the setup that duplicates the problem, but I
> have the minimal code to try to duplicate it.

This is a reply to an old thread, here is a link to the thread if anyone
interested:

http://groups.google.com/group/microsoft.public.vb.general.discussion/browse_thread/thread/41c1d7952bbe4a24/53219e...

I have managed to duplicate the problem that I had with CSocket, which
freezes/blocks my application for 52.087 Seconds in some systems, and it
turned out to be the call to gethostbyaddr() in CSocket.RecvDataToBuffer(),
rather than sendto() as I mentioned earlier. When I tested earlier, I used
MsgBoxes for debugging because I didn't have VB installed on the target
machine and I didn't know about OutputDebugString(), so VB was processing
messages while the MsgBox is shown, and I blamed the wrong function. MSDN
does say that gethostbyaddr() is a blocking function. It's used to as a
reverse lookup function to turn an IP address back to a host name, but since
I don't need the host name, I commented the call out, and my app no longer
blocks just by changing that single line of code. WSAAsyncGetHostByAddr() is
the non-blocking version, but the typical chat server/client app doesn't
need it. If one wants to implement that, search CSocket for
"RegisterWindowMessage", and add a third message and basically duplicate
whatever code "m_lngResolveMessage" appears in.

Also, some crashes occur because in some places CopyMemory() is used to copy
data returned by API functions, but some of these could fail and return a
Null pointer. This is the case inside RecvDataToBuffer(). After the call to
gethostbyaddr(), lngRetValue is not checked if it is 0. Another improvement
is checking if lPointer parameter is 0 in StringFromPointer(), just in case
something is passing Null to it.

How to duplicate: Run "ipconfig /release" from the command prompt and use
CSocket in UDP mode, add a label to your app showing the current time from a
Timer, then watch it freeze for at least for few seconds. In Windows 98, it
freezes for 52.087 Seconds. I also have a customer reported that he has
XP+SP2 and it freezes for about 50 seconds. I use XP+SP2, and it doesn't
freeze unless I use "ipconfig /release", then it freezes for about 2
seconds. I think in the past it was freezing for about 15 to 20
seconds(XP+SP2), but that was when I didn't know about the cause, and I
couldn't duplicate it.

Hope this helps...



--- Posted via news://freenews.netfront.net/ - Complaints to news@netfront.net ---
2 Answers

Henning

9/13/2011 3:34:00 PM

0


"Nobody" <nobody@nobody.com> skrev i meddelandet
news:j4nr9t$b3n$1@adenine.netfront.net...
> "Nobody" <nobody@nobody.com> wrote in message news:...
>> "Michel Posseth [MCP]" <msdn@posseth.com> wrote in message
>> news:OOeAm34vJHA.5584@TK2MSFTNGP04.phx.gbl...
>>> Hello Nobody
>>>
>>>
>>> You could use the form with the winsock control just as anny other class
>>> in the Activex executable , you can even create it late bound
>>>
>>> you can also just use the diverse coding solutions like this one ( wich
>>> is AFAIK one of the best outta there )
>>> http://www.a1vbcode.com/ap...
>>> http://www.planet-source-code.com/vb/scripts/ShowCode.asp?txtCodeId=52072&am...
>>>
>>> And free
>>
>> These are based on CSocket. One thing that I didn't mention earlier is
>> that sockets created with CSocket are non-blocking sockets. This happens
>> when WSAAsyncSelect() is called(according to the remarks section in
>> MSDN), which what CSocket is doing during initialization. This means that
>> the call to "sendto" should not block, and if there is a reason that it
>> would block, it should return immediately with error WSAEWOULDBLOCK.
>> That's not what I saw. "sendto" blocked for a long period before
>> returning. This seems to be a bug in the OS. WSAStartup() was called with
>> &H101, meaning version 1.1 in this case. I changed that to 2.0, but I
>> forgot if that made any difference. I don't have the setup that
>> duplicates the problem, but I have the minimal code to try to duplicate
>> it.
>
> This is a reply to an old thread, here is a link to the thread if anyone
> interested:
>
> http://groups.google.com/group/microsoft.public.vb.general.discussion/browse_thread/thread/41c1d7952bbe4a24/53219e...
>
> I have managed to duplicate the problem that I had with CSocket, which
> freezes/blocks my application for 52.087 Seconds in some systems, and it
> turned out to be the call to gethostbyaddr() in
> CSocket.RecvDataToBuffer(), rather than sendto() as I mentioned earlier.
> When I tested earlier, I used MsgBoxes for debugging because I didn't have
> VB installed on the target machine and I didn't know about
> OutputDebugString(), so VB was processing messages while the MsgBox is
> shown, and I blamed the wrong function. MSDN does say that gethostbyaddr()
> is a blocking function. It's used to as a reverse lookup function to turn
> an IP address back to a host name, but since I don't need the host name, I
> commented the call out, and my app no longer blocks just by changing that
> single line of code. WSAAsyncGetHostByAddr() is the non-blocking version,
> but the typical chat server/client app doesn't need it. If one wants to
> implement that, search CSocket for "RegisterWindowMessage", and add a
> third message and basically duplicate whatever code "m_lngResolveMessage"
> appears in.
>
> Also, some crashes occur because in some places CopyMemory() is used to
> copy data returned by API functions, but some of these could fail and
> return a Null pointer. This is the case inside RecvDataToBuffer(). After
> the call to gethostbyaddr(), lngRetValue is not checked if it is 0.
> Another improvement is checking if lPointer parameter is 0 in
> StringFromPointer(), just in case something is passing Null to it.
>
> How to duplicate: Run "ipconfig /release" from the command prompt and use
> CSocket in UDP mode, add a label to your app showing the current time from
> a Timer, then watch it freeze for at least for few seconds. In Windows 98,
> it freezes for 52.087 Seconds. I also have a customer reported that he has
> XP+SP2 and it freezes for about 50 seconds. I use XP+SP2, and it doesn't
> freeze unless I use "ipconfig /release", then it freezes for about 2
> seconds. I think in the past it was freezing for about 15 to 20
> seconds(XP+SP2), but that was when I didn't know about the cause, and I
> couldn't duplicate it.
>
> Hope this helps...
>
>
>
> --- Posted via news://freenews.netfront.net/ - Complaints to
> news@netfront.net ---

Have you tested how long it "freezes" after a ipconfig /renew?

/Henning


(nobody)

9/13/2011 3:38:00 PM

0

"Henning" <computer_hero@coldmail.com> wrote in message
news:j4nt5r$hja$1@dont-email.me...
> Have you tested how long it "freezes" after a ipconfig /renew?

Yes, no noticeable freeze/delay. I think it has something to do with DNS
server settings because it's a reverse name lookup that is causing the
freeze.