Re: VB6 Winsock action on Server
- From: "Phill W." <p-.-a-.-w-a-r-d@xxxxxxxxxxxxxxxxxxx>
- Date: Thu, 25 May 2006 15:37:20 +0100
jerry_ys wrote:
I have an app that needs to access a server using VB6 Winsock control. Should the app (server) on the server side be a std exe, or active x exe? which is better and why.
Option #3 - Windows Service.
AFAIK, both exe's and ActiveX exe's require someone to be logged onto the server machine in order that they can run. A Service will run all the time, even after everyone's gone home.
And yes; I know some people say don't write Windows Services in VB - I have and they've been run perfectly well (for several years now); you just need lots and /lots/ of error trapping code.
Next this server app will request services from a dll. My question is this. With multiple clients accessing this server app, will Winsock control keep the right requests for the right users and send back to the correct user the correct response?
Yes, but you have to use more than one of them, i.e. a Control Array.
Drop the WinSock control onto your Form, then set its Index property to zero. Then, (borrowed straight out of the WinSock Help)
Private Sub sckServer_ConnectionRequest( _
Index As Integer _
, ByVal requestID As Long _
)
Dim iIndex as Integer
If Index = 0 Then
iIndex = sckServer.Count
Load sckServer(iIndex)
sckServer(iIndex).LocalPort = 0
sckServer(iIndex).Accept requestID
End If
End Sub
As each Connection is accepted, you get another Socket loaded and operating, each dealing with its own connection.
Can someone please comment on this situation and explain how the objects on the server side keep track of clients?
As the code above demonstrates, a single "listener" socket waits for new, incoming connections. As each connection arrives, the "listener" hands the connection off to another socket; this socket then deals exclusively with that connection, leaving the "listener" waiting for any new ones.
I have not seen any clear explanation in books and manuals i have seen.
HTH,
Phill W.
.
- Prev by Date: Re: Error when I use .Show in VB 6.0
- Next by Date: Re: Playing & re-playing 7 .wav files
- Previous by thread: Launching IE from VB issues
- Next by thread: Re: VB6 Winsock action on Server
- Index(es):
Relevant Pages
|