Click to See Complete Forum and Search --> : SOS : Accepting multiple connections using Winsock


Vivek Desai
October 12th, 2001, 07:10 AM
I am using Winsock control in my application with TCP protocol. It is supposed to accept more than one client request. The problem is i am able to accept only one ConnectRequest. What do i need to do inorder to accept more than one client requests. I am following the hints given in MSDN exactly, but i feel i am doing something terribly wrong somewhere.

Thanks in advance,


Vivek (vivek.desai@patni.com or vivekjdesai@yahoo.com)

Cakkie
October 12th, 2001, 08:32 AM
You will need to use a control array or winsock controls. What I always do is create one winsock (sckListen) which I use to listen for incoming connection, and a control array (sckAccept) to accept the actual connctions. You will need to add 1 sckAccept, and give it index 0. Code looks something like this:

private iCnn as Integer

private Sub Form_Load()
sckListen.LocalPort = 1024
sckListen.Listen
Msgbox "Socket listening"
End Sub

private Sub sckListen_ConnectionRequest(RequestID as Long)
iCnn = iCnn + 1
Load sckAccept(iCnn)
sckAccept(iCnn).Accept RequestID
End Sub

private Sub sckAccept_DataArrival(Index as Integer, byval bytesTotal as Long)

Msgbox "someone is sending something over connection " & Index

End Sub




Tom Cannaerts
slisse@planetinternet.be

Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the universe trying to produce bigger and better idiots. So far, the universe is winning -- Rich Cook