Results 1 to 7 of 7

Thread: Winsock freezing the app

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Aug 2008
    Posts
    353

    Winsock freezing the app

    Hi guys,

    recently i made an app...that connects to a server with 30 connections at the same time with crypted data. and when the server gets that data it should send it back...to check if a serial is blacklisted or not.


    the problem is when i tried to simulate 30 instant connections to the server...winsock pretty much liked to freeze the app..and the only way to end it is ctrl alt del

    i tried to put DoEvents in the connect procedure like

    If Winsock1(Index).State = sckConnected Then
    .senddata
    DOEVENTS
    end if

    do events made the app a bit more clickable and moveable..but the app still likes to freeze itself...

    any idea? is it the winsock control? should i use api?


    cheers
    Thanks for helping me out.

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

    Re: Winsock freezing the app

    30 connections shuldn't be any problem at all using the Winsock control. I'd look elsewhere first.

    Using DoEvents() calls in Winsock programming is often a sign you're doing something wrong though. If it helps at all to sprinkle them in there it sounds suspicious.

    My guess would be that you are trying to blast data out over and over again (SendData calls) without waiting for SendComplete events. Without seeing some code though all we can do is guess wildly.

  3. #3

    Thread Starter
    Hyperactive Member
    Join Date
    Aug 2008
    Posts
    353

    Re: Winsock freezing the app

    wow cool answer

    i never did implement the sendcomplete thing :O

    how do i use it?

    ok will send out the code ...
    Thanks for helping me out.

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

    Re: Winsock freezing the app

    SendComplete events occur as a prompt from the Winsock control telling you that there is space in the outgoing buffers for more data, and that calling SendData will not block at that point.

    If you haven't written your program to work with SendComplete you may find you have some reworking to do.

  5. #5

    Thread Starter
    Hyperactive Member
    Join Date
    Aug 2008
    Posts
    353

    Re: Winsock freezing the app

    what i did is...
    ON CLICK :
    winsock.close
    winsock.connect .....

    WINSOCK CONNECT:
    if state = connected then
    send data
    doevents
    end if

    WINSOCK DATAARRIVAL:
    .GetData strReturn, vbString

    WINSOCK CLOSE:
    winsock.close
    edit the recieved string.ecc

    that's what i do
    Thanks for helping me out.

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

    Re: Winsock freezing the app

    Do you just do one SendData each time you Connect?

    Why would you check the State in the Connect event? Seems very redundant.

    There must be something else going on. I don't see anything in your psuedocode that would seem to cause your program to seize up, and calling DoEvents at the end of an event handler shouldn't do anything useful in itself. There must be a lot more going on.

  7. #7

    Thread Starter
    Hyperactive Member
    Join Date
    Aug 2008
    Posts
    353

    Re: Winsock freezing the app

    well when i connect i then choose if state=connected then send the data.
    and i get the data when the winsock closes the connection
    Thanks for helping me out.

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