Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Winsock Problem ?

Status
Not open for further replies.

HouDog

Programmer
Aug 14, 2003
54
0
0
CA
Hi All,

I have created a sample vb6 project with 1 form with a Winsock control on it.

Private Sub Form_Load()
Winsock1.Protocol = sckUDPProtocol
Winsock1.Bind 3000

End Sub

Private Sub Form_Terminate()
Winsock1.Close
End Sub

If I run it and open up the Task Manager, Project1.exe shows up under Applications and Processes as it should.

If I exit the app, Project1.exe is removed from the Applications tab BUT it persists in the Processes tab.

If I put the Winsock1.close in the FormUnload event, it does not get removed from either.

Is this normal? Or is it just my system ?

Thanks.
 
HouDog,

Haven't worked much with Winsock, but maybe you need to close the handle -- Winsock1.SocketHandle. Did you get the socket handle and store it in a variable when you initialized the winsock? If so, then you would have to use

CloseHandle(YourWinsockHandle)

I believe you should do this after you close the winsock.

HyperEngineer
If it ain't broke, it probably needs improvement.
 
Haven't worked much with the control either, but I assume that CloseHandel() shouldnt be neccessary; it's an activex control and it will probably close the handle internally.

My guess is that your Form_Terminate doesnt get fired; did you place a breakpoint there to check if it actiually terminates?

Greetings,
Rick
 
Hi, thanks for your replies. I also agree that I should not have to use CloseHandle().

I set the break point and it does stop in the Form Terminate Event and in fact, processing continues past my breakpoint. My IDE on the other hand freezes and goes into a Not Responding state.

HD.
 
I'd next try moving the Winsock1.CVlose out of the form_terminate event and put it under a button and see what happens then

Take Care

Matt
If at first you don't succeed, skydiving is not for you.
 
I'm wondering if anyone else has tried this and is experiencing the same problem or if it is simply my machine with possible a bad runtime/control or something...

I moved the winsock1.close to a button.

I then do a "make project1.exe".

when I run project1.exe, it shows up both in my applications list and processes list under Task Manager.

When I click the button, and close Project1.exe...it goes into a non-responding state on the application list and remains in the processes list.

Thanks, HD.
 
I've just done a quick project to test this, all I can say is that it works as expected for me!

W2K with VB6 + sp6

Take Care

Matt
If at first you don't succeed, skydiving is not for you.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top