Results 1 to 18 of 18

Thread: [RESOLVED] More connections with one winsock

  1. #1

    Thread Starter
    Member
    Join Date
    Apr 2007
    Location
    Kurdistan, Slemani
    Posts
    43

    Resolved [RESOLVED] More connections with one winsock

    Can I only connect as one client with a winsock?
    winsock.Connect -
    will get me connected to the server, but if I want to connect to the server twice at the same time with the same sock, how can I do that?
    Or do I have to create another sock?

  2. #2
    Interweb adm/o/distrator Paul M's Avatar
    Join Date
    Nov 2006
    Location
    Australia, Melbourne
    Posts
    2,306

    Re: More connections with one winsock

    I would probably use an array of winsocks.

  3. #3
    Frenzied Member
    Join Date
    Aug 2000
    Location
    O!
    Posts
    1,177

    Re: More connections with one winsock

    Why would you need to have more than one connection to the same server? Can you tell us what you are trying to do?

  4. #4

    Thread Starter
    Member
    Join Date
    Apr 2007
    Location
    Kurdistan, Slemani
    Posts
    43

    Re: More connections with one winsock

    How can I use an array with the winsock?

    ccoder:
    I just want to play around with my code, no big reason.

  5. #5
    Interweb adm/o/distrator Paul M's Avatar
    Join Date
    Nov 2006
    Location
    Australia, Melbourne
    Posts
    2,306

    Re: More connections with one winsock

    vb Code:
    1. Dim i as integer
    2. i = 1
    3.     Do Until i = Val#(TxtSocks.Text)
    4.       Load Winsock(i)
    5.       i = i + 1
    6.     Loop
    That will just load so many winsock as you say so in TxtSocks

  6. #6

    Thread Starter
    Member
    Join Date
    Apr 2007
    Location
    Kurdistan, Slemani
    Posts
    43

    Re: More connections with one winsock

    Doesn't I have to make the winsock as an array first?
    Or can I do it like this:
    winsock(0).RemoteHost = txtIp
    winsock(0).RemotePort = txtPort
    winsock(0).Connect
    (And for the dataArrival)
    winsock(0).SendData "x"

    and so on.. with the next array variable? Like:
    winsock(1).RemoteHost = txtIp
    winsock(1).RemotePort = txtPort
    winsock(1).Connect
    (And for the dataArrival)
    winsock(1).SendData "y"

    edit:
    btw, thanks for all the help
    Last edited by Kurdistan; May 3rd, 2007 at 12:38 PM.

  7. #7

    Thread Starter
    Member
    Join Date
    Apr 2007
    Location
    Kurdistan, Slemani
    Posts
    43

    Re: More connections with one winsock

    Solved my problem
    Made a control array with the winsock on the form, and now just doing as my code above, with Load Winsock(5) and so on

    EDIT:
    Problem :/ It only sends the last one With:
    winsock(0).SendData
    winsock(1).SendData
    it skips the first, and only sends the second. Any ideas?
    Last edited by Kurdistan; May 3rd, 2007 at 02:04 PM.

  8. #8
    Interweb adm/o/distrator Paul M's Avatar
    Join Date
    Nov 2006
    Location
    Australia, Melbourne
    Posts
    2,306

    Re: More connections with one winsock

    Yea you could also do it the way that worked for you But that would mean more controls. Anyway well done and good luck

  9. #9

    Thread Starter
    Member
    Join Date
    Apr 2007
    Location
    Kurdistan, Slemani
    Posts
    43

    Re: More connections with one winsock

    Yeah, Thanks But it still just sends the last data and skips the others :/

  10. #10
    PowerPoster dilettante's Avatar
    Join Date
    Feb 2006
    Posts
    24,487

    Re: More connections with one winsock

    This sounds like a well known bug that was fixed in VB6 SP6. What service pack are you at?

  11. #11

    Thread Starter
    Member
    Join Date
    Apr 2007
    Location
    Kurdistan, Slemani
    Posts
    43

    Re: More connections with one winsock

    Not sure, Have'nt upgraded my VB6, so its probably at SP0.
    But it works if I use a timer with 1 second between the sends.

  12. #12
    New Member gnk_on_vb's Avatar
    Join Date
    May 2007
    Location
    Pune, India
    Posts
    14

    Re: More connections with one winsock

    Previously I was also having the same problem.
    I also implemented it using the timer to give a gap between the send data command for more than one connection.
    Now i have downloaded the vb6 updates from microsoft site. from following url

    http://www.microsoft.com/downloads/d...displaylang=en

    Now i don't need to keep a time gap in sending data.

    Thanks

  13. #13

    Thread Starter
    Member
    Join Date
    Apr 2007
    Location
    Kurdistan, Slemani
    Posts
    43

    Re: More connections with one winsock

    Thanks, hope it works for me too

  14. #14
    PowerPoster dilettante's Avatar
    Join Date
    Feb 2006
    Posts
    24,487

    Re: [RESOLVED] More connections with one winsock

    For future reference by others, later service packs fix a number of Winsock control issues. Some of the nastier ones are:

    FIX: Winsock Control SendData Only Works Over the Latest Connection

    Winsock control may fire the DataArrival event after the Close event

    Always be sure to install the very latest service pack you can get, which is pretty much SP6 unless Microsoft issues a new one someday. You only need to install the latest one, since each SP is cumulative.

  15. #15

    Thread Starter
    Member
    Join Date
    Apr 2007
    Location
    Kurdistan, Slemani
    Posts
    43

    Re: [RESOLVED] More connections with one winsock

    Do you think it's a bug that I get the errormessage:
    "Run-time error '40006':
    Wrong protocol or connection state for the requested transaction or request"
    when I connect with more than 400 connections to a server?
    Want to try out how many users my application can handle.
    Or is there anyother control rather than winsock?

  16. #16
    Interweb adm/o/distrator Paul M's Avatar
    Join Date
    Nov 2006
    Location
    Australia, Melbourne
    Posts
    2,306

    Re: [RESOLVED] More connections with one winsock

    That often occurs when the user uses the SendData or GetData methods before the winsock has connected.

    Also have a look here....
    http://download.microsoft.com/downlo...vbrun60sp5.exe

  17. #17

    Thread Starter
    Member
    Join Date
    Apr 2007
    Location
    Kurdistan, Slemani
    Posts
    43

    Re: [RESOLVED] More connections with one winsock

    Strange, because it connects up to 350 socks, and then I get the error.
    Or sometimes even less socks.

    Thanks, I'll try that one too.

  18. #18
    Junior Member
    Join Date
    Feb 2007
    Posts
    28

    Re: [RESOLVED] More connections with one winsock

    It probably would depend on the ports as well.

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