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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Winsock Question 1

Status
Not open for further replies.

azrobert

Programmer
Apr 27, 2002
392
US
Hello all,

I am writing a client / server application with one server and multiple clients to receive orders from different locations. I am creating new winsocks as per msdn example and have everything working so far. My question is how do I need to close or dispose of the created winsock controls after the data transmission is done ? my server app never really closes and I imagine i will run into several problems if i just keep creating new winsocks.......

Private Sub sckServer_ConnectionRequest(Index As Integer, ByVal requestID As Long)
If Index = 0 Then
intMax = intMax + 1
Load sckServer(intMax)
sckServer(intMax).LocalPort = 0
sckServer(intMax).Accept requestID
Debug.Print intMax
End If
End Sub
 
Hi,

Once you are finished sending and/or receiving data just put a line of code in saying

sckserver.close

and this will close the connection.
 
I am closing the winsock after all data is passed back and forth. My worry is that as I continualy create new controls as new connections arive there will be problems. I have tried re-setting my "counter" to 1 to start over assigning winsock index but I get an error of object already loaded.
any one have any ideas ? I am sure this is a common problem and I have missed the answer......
 
azrobert,

Am not very familiar with the Winsock control but I guess you are creating an intial one at design time with an index of zero and then creating others in a Control Array using the Load Statement. Therefore when you are done with an element in the Control Array try using the UnLoad Statement on it.

Checkout Unload in VB6 help.

HTH Hugh
 
Thanks Hugh,

I had to take an unusual approach to unloading the created controls but it looks like that is on the right path....
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top