Hello everybody
I'm a new member in this forum and I have good information in vb6
now my problem in the winsock tool
and my Q. is : How I can allow 2 clients to connect to 1 server in the same time ?
please help me .
yours
Printable View
Hello everybody
I'm a new member in this forum and I have good information in vb6
now my problem in the winsock tool
and my Q. is : How I can allow 2 clients to connect to 1 server in the same time ?
please help me .
yours
Welcome to the forums magic_net.
Have a look at the attached zip file in this thread. Although the example is for a chat room, it does address the issues of using Winsock with multiple people.
In addition, there are a wide number of past posts concerning Winsock that you may find useful. If you click on the Search button, and type in winsock, you will get a listing of them all.
I hope this helps. :)
thanx hack
I'll try the file
Hey magic,
Hack my guide is only a basic 1 on 1 chat program :)
But to transform it to a mulituser is very simple, you have to have a control array of winsocks to do this. (So copy and paste the winsock in the server side) now then we need to change a few routines within the server, note the client does not change.
we will also need to change the code in this sub slightlyVB Code:
Private Sub winsock_DataArrival(ByVal bytesTotal As Long) 'we will change this to Private Sub winsock_DataArrival(Index as integer, ByVal bytesTotal As Long)
VB Code:
winsock.getdata 'would change to winsock(Index).getdata
Also not here if your server gets data from a specific client normal practice is that the server then sends this to every other client who is connected, to do that the follwoing code is used...
VB Code:
Winsock(Index).getdata data for i = 0 to winsock.ubound - 1 if winsock.sckconnected = true then winsock(I).senddata data end if doevents next i
Theres one last sub we need to change and thats the conntion request event
Change to the following (Not there are much better ways memory wise to do this but for beggining purposes this does the job!)
VB Code:
Private Sub Winsock_ConnectionRequest(Index As Integer, ByVal RequestID As Long) Load Winsock(Winsock.UBound + 1) Winsock(Winsock.UBound).Accept RequestID End Sub
Hope that helps, i've just written it blind and its a while since I've played with some winsock so hope that helps you :)
Pino
Edit - hack is correct I forgot there was another user mentioning how to make it multi-user
Bah all my typing is worthless :blush:
I was gonna say...I know these old eyes ain't what they used to be, but I could have sworn there was multiuser code in there. :)Quote:
Originally Posted by Pino
Sorry about that, the actual file itself is only single user! Anyhows let us know if you are struggling with anything I'll do my best to fix you up :)
And once again sorry hack :) ;)
Pino