Results 1 to 6 of 6

Thread: help me with winsock

  1. #1

    Thread Starter
    New Member
    Join Date
    May 2005
    Posts
    4

    help me with winsock

    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

  2. #2
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333

    Re: help me with winsock

    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.

  3. #3

    Thread Starter
    New Member
    Join Date
    May 2005
    Posts
    4

    Re: help me with winsock

    thanx hack
    I'll try the file

  4. #4
    PowerPoster
    Join Date
    Dec 2003
    Posts
    4,787

    Re: help me with winsock

    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.

    VB Code:
    1. Private Sub winsock_DataArrival(ByVal bytesTotal As Long)
    2.  
    3. 'we will change this to
    4.  
    5. Private Sub winsock_DataArrival(Index as integer, ByVal bytesTotal As Long)
    we will also need to change the code in this sub slightly

    VB Code:
    1. winsock.getdata
    2.  
    3. 'would change to
    4.  
    5. 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:
    1. Winsock(Index).getdata data
    2.  
    3. for i = 0 to winsock.ubound - 1
    4.      if winsock.sckconnected = true then
    5.             winsock(I).senddata data
    6.      end if
    7. doevents
    8. 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:
    1. Private Sub Winsock_ConnectionRequest(Index As Integer, ByVal RequestID As Long)
    2.  
    3.  
    4. Load Winsock(Winsock.UBound + 1)
    5. Winsock(Winsock.UBound).Accept RequestID
    6.  
    7. 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

  5. #5
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333

    Re: help me with winsock

    Quote Originally Posted by Pino
    Edit - hack is correct I forgot there was another user mentioning how to make it multi-user

    Bah all my typing is worthless
    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.

  6. #6
    PowerPoster
    Join Date
    Dec 2003
    Posts
    4,787

    Re: help me with winsock

    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

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width