Valhalla Legends Archive

Programming => General Programming => Visual Basic Programming => Topic started by: brew on April 14, 2007, 11:05 AM

Title: URLS in winsock
Post by: brew on April 14, 2007, 11:05 AM
Did anyone ever wonder, why, if you connect to a text ip/url/whatever you want to call it such as bnls.valhallalegends.com with a winsock, it works fine, until you try to unload your form. About half the time it freezes and vb6 crashes. Anyone know why, or a fix for this? (it works fine when compiled) I always end up having to put in the acual ip -.-
Title: Re: URLS in winsock
Post by: Barabajagal on April 14, 2007, 11:18 AM
Uhm... Never happens for me.
Title: Re: URLS in winsock
Post by: l2k-Shadow on April 14, 2007, 11:41 AM
that usually doesn't happen unless you try to do something that is "not what VB is for" things.. such as changing the address of the callback function so that you can parse it yourself - like when implementing winsock API into VB rather than using the control.

You could also attempt to look into getting the IP address yourself rather than letting the control do it for you, try looking into this lovely function here: http://msdn2.microsoft.com/en-us/library/ms738520.aspx (http://msdn2.microsoft.com/en-us/library/ms738520.aspx)
Title: Re: URLS in winsock
Post by: brew on April 14, 2007, 12:27 PM
You know what, vb6 is sooo limited. I'm honestly thinking about converting to C++ completely.
Title: Re: URLS in winsock
Post by: Barabajagal on April 14, 2007, 12:35 PM
Since you already know some VB, try PowerBasic before moving to an entire different language family. You can find a PB download on a torrent site somewhere...
Title: Re: URLS in winsock
Post by: l2k-Shadow on April 14, 2007, 12:51 PM
Quote from: brew on April 14, 2007, 12:27 PM
You know what, vb6 is sooo limited. I'm honestly thinking about converting to C++ completely.

Smart choice :)
Title: Re: URLS in winsock
Post by: Joe[x86] on April 15, 2007, 10:09 PM
If you don't know why the Winsock stops working when you unload your Form, you should not even consider considering C++.
Title: Re: URLS in winsock
Post by: Grok on April 16, 2007, 12:02 AM
Quote from: Joex86] link=topic=16616.msg168019#msg168019 date=1176692996]
If you don't know why the Winsock stops working when you unload your Form, you should not even consider considering C++.

Why not?  I don't see a relationship between not understanding the internals of someone else's COM component with learning non-COM winsock programming in C++.
Title: Re: URLS in winsock
Post by: Barabajagal on April 16, 2007, 12:21 AM
I think it's a common sense issue... If an object contains other objects and that object disappears, it's only common sense to assume the objects contents will also disappear.
Title: Re: URLS in winsock
Post by: Explicit on April 16, 2007, 12:29 AM
Quote from: RεalityRipplε on April 16, 2007, 12:21 AM
I think it's a common sense issue... If an object contains other objects and that object disappears, it's only common sense to assume the objects contents will also disappear.

It would also involve how the objects free memory.
Title: Re: URLS in winsock
Post by: Grok on April 17, 2007, 11:52 AM
Quote from: RεalityRipplε on April 16, 2007, 12:21 AM
I think it's a common sense issue... If an object contains other objects and that object disappears, it's only common sense to assume the objects contents will also disappear.

Read the original post.  He's not complaining about the connection disappearing, but rather the application freezing or crashing.  Quite a different thing.

Brew, first make sure you are running Service Pack 6 (http://www.microsoft.com/downloads/details.aspx?familyid=7b9ba261-7a9c-43e7-9117-f673077ffb3c&displaylang=en) for VB6 and try your program again.  Unloading the form should cause the contained controls to unload as well.  The Winsock control, being contained, should close the connection and free its resources gracefully.  If you're using an older version that was since fixed, the SP6 should help.

If that doesn't fix the problem; create a new VB6 project, add a winsock control, add minimal code to connect to bnls, then test whether you can reproduce the error.  If the sample still gets the error, post it on the forum for someone to verify your result on their own PC.
Title: Re: URLS in winsock
Post by: brew on April 17, 2007, 03:28 PM
Here ya' go:
http://freewebs.com/brew1337/test.zip
Just unload the form by "x-ing it out"
Title: Re: URLS in winsock
Post by: Grok on April 18, 2007, 03:28 PM
Opened it in VB6, w/sp6, ran it, clicked Command1, then closed the form using the 'x' on caption bar.  No error, no crash, it just closed as I expected it to do.
Title: Re: URLS in winsock
Post by: Imperceptus on April 18, 2007, 06:41 PM
I have had vb6 crash or hang with use of winsock. Check the state of your socket.  You get so caught up in vb6 with do a little test then do more then test that things are still going on with winsock when you try to stop.(Atleast I think this is whats going on). I haven't found a solution.
Title: Re: URLS in winsock
Post by: brew on April 18, 2007, 08:28 PM
Even with Service Pack 6, it hangs then crashes on me. However I have made another observation: When I end the program using the "stop" button on the toolbar of the VB6 IDE it seems to stop perfectly, then any other time when I run and unload the form, it works fine. But if I did not end it before unloading the form, it does the same thing. I'm really not sure what to make of this.
Title: Re: URLS in winsock
Post by: Imperceptus on April 18, 2007, 11:26 PM
make sure your controls aren't bound to doing anything at the moment? i dunno.
Title: Re: URLS in winsock
Post by: Barabajagal on April 18, 2007, 11:45 PM
You aren't subclassing, are you?