Results 1 to 2 of 2

Thread: Multiple sockets for server apps

  1. #1

    Thread Starter
    New Member
    Join Date
    May 2001
    Location
    United Kingdom
    Posts
    2

    Multiple sockets for server apps

    I am developing a server application in vb and having been experimenting with different ways of handling multiple connections. Winsock control arrays seem to be the most effective but if anyone has any suggestions ^_^. One of the problems i have encountered is that when a socket closes you use the Unload command to remove it from memory leaving a gap in the control array, hwo do you then handle the next connection? make a new control UBound + 1 or use the gap? if so how?

    If anyone has done this type of programming before or feels they could help whatsoever please do.

    AIM: BAO ColdFusion (used the most)
    ICQ: 55771032 (if im not around leave me a msg)
    e-mail: [email protected]

    thanks,

    ColdFusion

  2. #2
    Retired VBF Adm1nistrator plenderj's Avatar
    Join Date
    Jan 2001
    Location
    Dublin, Ireland
    Posts
    10,359
    Any times Ive had to write server apps that accept multiple connections, data processing is only ever event driven.

    So if socket 50 wants me to do something, I do it and give the data to socket 50.

    But if you have write data to all your open socks every so often, then I'd use an array that just says whether they're open or not :

    Code:
    dim isSockThere() As Boolean
    
    'somewhere else in code
    Winsock1(i).Close
    Unload Winsock1(i)
    isSockThere(i) = False
    
    'then when writing data 
    For i = 0 To Winsock1.Count -1
        If (isSockThere(i)) Then Winsock1.SendData "iasdjosia"
    Next i
    Id do something like that ...
    Microsoft MVP : Visual Developer - Visual Basic [2004-2005]

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