Results 1 to 4 of 4

Thread: Help with winsock sending data

  1. #1

    Thread Starter
    New Member
    Join Date
    May 2006
    Location
    UK
    Posts
    2

    Help with winsock sending data

    Hello,

    I've been using vb6 for a few month now and have experienced some problems using winsock.

    I have a function for sending data from the server like this:

    VB Code:
    1. Function SendData(Index As Integer, Data As String)
    2.     frmServer.ServerSck(Index).SendData & "%$"
    3. End Function

    when the server recieve data I pass it to a function for proccessing the data, somthing like this:

    VB Code:
    1. Function ProcData(Index As Integer, Data As String)
    2.     Dim DataA() As String
    3.     Dim DataPacket As String
    4.     Dim DataPacketA() As String
    5.     Dim i As Integer
    6.    
    7.     DataA() = Split(Data, "%$")         'Split up the incoming commands
    8.    
    9.     For i = 0 To UBound(DataA) - 1
    10.         If DataA(i) <> "" Then
    11.             DataPacket = DataA(i)
    12.             DataPacketA() = Split(DataPacket, "|")      'Split the paramaters
    13.            
    14.             Select Case LCase(DataPacketA(0))
    15.                 Case "login"
    16.                     'I would call the login function here
    17.             End Select
    18.         End If
    19.        
    20.         DoEvents
    21.     Next i
    22. End Function

    when I call my login function it all works fine till it gets to the senddata calls, at the end of the function. I have lots of calls to other functions that in turn use the sendData function to send appropriate data, kind of like this:

    VB Code:
    1. Call SendData Index, "Data"
    2. Call Function1 Index
    3. Call Function2 Index
    4. Call SendData Index, "Data2"
    5. Call Function3 Index

    My problem is when it gets to all those calls it never sends everything it should. I tried using doevents and it fixed some of them, but usual led to it working somtimes and not others. I've read that using doevents can cause problems later on in development.

    I also use a encryption class before sending the data if that would make any difference in data being sent or not.

    Can anyone help?
    If anyone needs more info or to see more of my code I'll be happy to post it.
    Also the server is used for a custom mud.


    Any help is appreciated.


    Thanks

  2. #2
    New Member
    Join Date
    May 2006
    Posts
    1

    Re: Help with winsock sending data

    you mean nothing of your data is sent?

  3. #3

    Thread Starter
    New Member
    Join Date
    May 2006
    Location
    UK
    Posts
    2

    Re: Help with winsock sending data

    What I mean is only some data gets send.

    When a client logs in I need to send if various information about the account etc

    The problem is that all my calls to the functions that send data never get called

    eg

    VB Code:
    1. Call SendData Index, "Log in ok"
    2. Call SendData Index, "Info"
    3. Call Function1 Index
    4. Call Function2 Index
    5. Call Function3 Index

    Function1 - 3 are just functions similar to sendData.

    The client would only recieve the first 2 and on odd times the 3rd.

  4. #4
    Hyperactive Member
    Join Date
    Aug 2002
    Location
    UK
    Posts
    417

    Re: Help with winsock sending data

    hi i don;t know if this will work, but I had the same sort of problum a few days bk when building a messanger program, anyway I used DoEvents after each send ,

    anyway Give it a try hope it may help

    Code:
    Function SendData(Index As Integer, Data As String)
        frmServer.ServerSck(Index).SendData & "%$" & vbcrlf
        DoEvents
    End Function
    When your dreams come true.
    On error resume pulling hair 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