For Programmers: Free Programming Magazines  


Home > Archive > Visual Basic > January 2005 > Control array inside ActiveX DLL question









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author Control array inside ActiveX DLL question
fortunataw

2005-01-27, 8:55 pm

Please ignore my posting.
I figured it out my problem.
My problem is like the following:
client 1 connect -> m_iSockets = 1
client 2 connect -> m_iSockets = 2
client 1 disconnect -> m_iSockets = 2
client 3 connect, at this time I got the error
360 "Object already loaded".
It was because the system tried to load f.tcpServer(2)
which is loaded already.
I ended up using an array with flag 0 or 1, 0 being the
socket is not used, 1 being the socket is used.
When I add a control, I set the flag of the array element
to 1, when I delete a control I set the array element to
0.

Thanks.


>-----Original Message-----
>I have a main application that calls an ActiveX DLL
>(prWinsockWrapper.dll) which contains a form with

winsock
>control and a public class (clsWinsockMain). I thank you
>Terry and Ken for the codes.
>The control events are wrapped into the clsWinsockMain.
>The main application then instantiate the
>prWinsockWrapper.clsWinsockMain class.
>
>I need the winsock control to be able to accept more

than
>one connection request. For this, I need to create a
>control array for the Winsock control.
>
>My question is, where should I increment the index of

the
>Winsock control array ? Should I do this inside the
>clsWinsockMain or in the main application ? Currently I
>am doing it inside the clsWinsockMain, but sometimes

(not
>all the time) I will get an error "object has been
>loaded" or something like that. This seems to happen

when
>multiple users call/use the class at the same time.
>
>Thanks a lot.
>
>These are my current codes from
>prWinsockWrapper.clsWinsockMain:
>
>'m_iSockets is the number of items in the control array,
>'shall I increment and decrement this inside this class ?
>Private m_iSockets As Integer
>'frmWinsock is the form inside the class.
>'This form contains the Winsock control
>Private WithEvents f As frmWinsock
>
>Private Sub Class_Initialize()
> m_iSockets = 0
> Set f = New frmWinsock
>end Sub
>
>Private Sub Class_Terminate()
> Unload f
> Set f = Nothing
>end sub
>
>Private Sub f_fConnectionRequest(index As Integer, ByVal
>requestID As Long)
> If index = 0 Then
> m_iSockets = m_iSockets + 1
> Load f.tcpServer(m_iSockets)
> f.tcpServer(m_iSockets).LocalPort = m_lLocalPort
> f.tcpServer(m_iSockets).Accept requestID
> End If
> RaiseEvent wConnectionRequest(index, requestID)
>End Sub
>
>Private Sub f_fClose(index As Integer)
> f.tcpServer(index).Close
> Unload f.tcpServer(index)
> m_iSockets = m_iSockets - 1
> RaiseEvent wClose(index)
>End Sub
>
>These are current codes from the main application that
>calls the prWinsockWrapper.DLL (I include
>prWinsockWrapper.dll in the project's reference):
>Private WithEvents objWinsock As
>prWinsockWrapper.clsWinsockMain
>
>sub Form_Load()
> Set objWinsock = New prWinsockWrapper.clsWinsockMain
>
> objWinsock.Connect txtPort.Text
>end sub
>.
>

Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2009 codecomments.com