PDA

Click to See Complete Forum and Search --> : Help with winsock sending data


Fraser_
May 11th, 2006, 05:47 AM
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:

Function SendData(Index As Integer, Data As String)
frmServer.ServerSck(Index).SendData & "%$"
End Function

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

Function ProcData(Index As Integer, Data As String)
Dim DataA() As String
Dim DataPacket As String
Dim DataPacketA() As String
Dim i As Integer

DataA() = Split(Data, "%$") 'Split up the incoming commands

For i = 0 To UBound(DataA) - 1
If DataA(i) <> "" Then
DataPacket = DataA(i)
DataPacketA() = Split(DataPacket, "|") 'Split the paramaters

Select Case LCase(DataPacketA(0))
Case "login"
'I would call the login function here
End Select
End If

DoEvents
Next i
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:

Call SendData Index, "Data"
Call Function1 Index
Call Function2 Index
Call SendData Index, "Data2"
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

the_nomad
May 11th, 2006, 10:35 AM
you mean nothing of your data is sent?

Fraser_
May 11th, 2006, 11:35 AM
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

Call SendData Index, "Log in ok"
Call SendData Index, "Info"
Call Function1 Index
Call Function2 Index
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.

dreamvb
May 14th, 2006, 10:12 PM
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


Function SendData(Index As Integer, Data As String)
frmServer.ServerSck(Index).SendData & "%$" & vbcrlf
DoEvents
End Function