Click to See Complete Forum and Search --> : Connecting with WinSock


udipr
September 10th, 2001, 05:12 AM
Hello

How can I connect more then two users with winsock. ??? (like in chat)

Thanks

Cakkie
September 10th, 2001, 05:38 AM
The thing you need to do is to make a control array. Doing this at run-time is very flexible, and can serve up to as many connections as your system is capable of (read as hardware restrictions). To do this, place one Winsock control on teh form, give it index 0. When a connection request comes in, create a socket, and accept the connection.

private ConnectionCount as Integer

private Sub Winsock1_ConnectionRequest(Index as integer, RequestID as long)
ConnectionCount = ConnectionCount + 1
Load Winsock1(ConnectionCount)
Winsock1(ConnectionCount).Accept RequestID
End Sub

private Sub Winsock1_DataArrival(Index as integer, .....
Dim strData as string
Winsock1(Index).GetData strData
Msgbox "incoming data from connection " & Index & vbcrlf & strData
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

urs
September 10th, 2001, 05:51 AM
what Cakkie said is right
but to get a clear idea u can go to
planetsourcecode.com
there u will find many chat projects
i hope there u will get what u want

best of luck

udipr
September 10th, 2001, 06:42 AM
What I do with the LocalPort and RemotePort ?
Can I use same ports for all clients ?

Cakkie
September 10th, 2001, 07:39 AM
Oops, forgot, you need to set the localport. Typically, start counting from a number, and add the ConnectionCount to it. Do this before you issue the Accept method.

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

udipr
September 10th, 2001, 08:11 AM
I found.
Thanks.

I use with same port for all users