Mirage Source http://web.miragesource.net/forums/ |
|
Zlip mixed with IOCP+PackerBuffer http://web.miragesource.net/forums/viewtopic.php?f=201&t=572 |
Page 1 of 4 |
Author: | William [ Sat Sep 30, 2006 12:21 pm ] |
Post subject: | Zlip mixed with IOCP+PackerBuffer |
So, I can't seem to get ZLip working correctly serverside. Client side was easy. You see after installing IOCP and the packet buffer to it, I wanted to try Zlip. But the packetbuffer sub SendQueuedData had to be changed in order to work with IOCP (thanks Obsidian). So here is my SendQueuedData sub with IOCP and the packet buffer added: Code: Sub SendQueuedData() Dim i As Integer, n As Long Dim TmpStr As String Dim dbytes() As Byte Dim Sploc As Integer Dim ECloc As Integer Dim lR As Long For i = 1 To MAX_PLAYERS TmpStr = "" With ConQueues(i) If Not .Lock Then On Error Resume Next If GameServer.Sockets(i).Socket Is Nothing Then .Lines = "" End If If Len(.Lines) = 0 And QueueDisconnect(i) = True Then Call CloseSocket(i) QueueDisconnect(i) = False Else If Len(.Lines) > 0 Then If Len(.Lines) < MAX_PACKETLEN Then TmpStr = .Lines Else TmpStr = Left(.Lines, MAX_PACKETLEN) End If .Lines = Right(.Lines, Len(.Lines) - Len(TmpStr)) End If End If If Len(TmpStr) > 0 Then dbytes = StrConv(TmpStr, vbFromUnicode) If IsConnected(i) Then 'Call EnigmaEncrypt(dbytes, "travis") GameServer.Sockets(i).WriteBytes dbytes DoEvents End If End If End If End With Next DoEvents End Sub This is what Zlib want me to replace it with: Code: Sub SendQueuedData()
Dim ECloc As Integer Dim lR As Long Dim i As Integer, N As Long Dim TmpStr As String For i = 1 To MAX_PLAYERS If frmServer.lblOnOff.Caption = "OFFLINE" Then Exit Sub TmpStr = "" With ConQueues(i) If Not .Lock Then If frmServer.Socket(i).State <> 7 Then .Lines = "" End If If Len(.Lines) = 0 And QueueDisconnect(i) = True Then Call CloseSocket(i) QueueDisconnect(i) = False Else If Len(.Lines) > 0 Then If Len(.Lines) < MAX_PACKETLEN Then TmpStr = .Lines Else TmpStr = Left(.Lines, MAX_PACKETLEN) End If ECloc = InStr(1, .Lines, END_CHAR) TmpStr = Left(.Lines, ECloc) .Lines = Right(.Lines, Len(.Lines) - Len(TmpStr)) End If End If If Len(TmpStr) > 0 Then Debug.Print "Sending: " & TmpStr TmpStr = Compress(TmpStr, lR) TmpStr = lR & SEP_CHAR & TmpStr Call frmServer.Socket(i).SendData(TmpStr) End If End If End With DoEvents Next End Sub If you look close, you will se some differences between them. And I need to know how to make Zlib work with IOCP and the packetbuffer.So somehow they should be mixed together. THis is out of my knowledge so I need some help. Related Topics Zlib: http://ms.shannaracorp.com/backup-forum ... sp?TID=218 PacketBuffer: http://ms.shannaracorp.com/backup-forum ... sp?TID=224 IOCP: http://ms.shannaracorp.com/backup-forum ... sp?TID=120 |
Author: | Matt [ Sat Sep 30, 2006 1:07 pm ] |
Post subject: | |
You keep saying Zlip, instead of Zlib. Why don't you compare all of them, find the differences, and just add all the differences into one sub? |
Author: | Robin [ Sat Sep 30, 2006 1:10 pm ] |
Post subject: | |
I added ZLib into one of my sources. It worked fine, except when it was compiled. It only worked correctly when it was run in VB. Does anyone else have that problem? |
Author: | Misunderstood [ Sat Sep 30, 2006 1:16 pm ] |
Post subject: | |
You don't understand what zlib does do you? Well here it is. Just using strings with zlib: Code: If Len(TmpStr) > 0 Then
TmpStr = Compress(TmpStr, lR) TmpStr = lR & SEP_CHAR & TmpStr dbytes = StrConv(TmpStr, vbFromUnicode) If IsConnected(i) Then GameServer.Sockets(i).WriteBytes dbytes DoEvents End If End If does zlib need a string to enrypt? or can it encrypt byte arrays? If it can decrypt byte arrays faster(which it should) theres probably a better way. |
Author: | William [ Sat Sep 30, 2006 1:43 pm ] |
Post subject: | |
@Advocate: Just noticed I wrote both Zlib and Zlip.. hehe anyway, just a spelling error.. @Misunderstood: If I understood Zlib correctly, I think it Compresses the data (encrypts it). And it doesn't make the packets bigger, that why Zlib is so good. And it also allows for decryption. WHich means that the encryption actually is a compression.. well anyway. The code you posted, is that only what should be changed? @Kite: Dont know yet, cause I aint got it working yet. ALthough I will try with Miss code first. |
Author: | Misunderstood [ Sat Sep 30, 2006 2:28 pm ] |
Post subject: | |
Well it is the only place data is sent to the client right? If it is, then yes, otherwise, no. |
Author: | Spodi [ Sat Sep 30, 2006 2:45 pm ] |
Post subject: | |
Most any compression you find will make packets bigger, or not compress them more then a byte or two, unless you have packets >150 bytes (in which case, for a 2D game, you're already ****ed). ZLib compresses in byte arrays, as does like every other encryption / compression. Quote: dbytes = StrConv(TmpStr, vbFromUnicode)
That is turning your string into a byte array right there. |
Author: | William [ Sat Sep 30, 2006 2:55 pm ] |
Post subject: | |
Zlib Home Site wrote: the compression method currently used in zlib essentially never expands the data.
|
Author: | Spodi [ Sat Sep 30, 2006 3:04 pm ] |
Post subject: | |
I have done plenty of testing with tons of different compression algorithms on packets ranging from like 3 bytes to 300 bytes. "Essentially never" may not apply to insanely small data. |
Author: | William [ Sat Sep 30, 2006 3:16 pm ] |
Post subject: | |
Okay Im following your advice, and will not add Zlib. Thanks |
Author: | Spodi [ Sat Sep 30, 2006 3:43 pm ] |
Post subject: | |
Glad I could be of help. |
Author: | pingu [ Sat Sep 30, 2006 9:44 pm ] |
Post subject: | |
I'd add it more of a conditional type of thing. You know, adding it for the biggest packets and such. |
Author: | William [ Sat Sep 30, 2006 9:54 pm ] |
Post subject: | |
pingu wrote: I'd add it more of a conditional type of thing. You know, adding it for the biggest packets and such.
I don't see a reason for that, either you have it for all or none. That my opinion at least. And I don't think the biggest once will help you anything, but let Spodi respond |
Author: | Spodi [ Sat Sep 30, 2006 10:12 pm ] |
Post subject: | |
Well you shouldn't have packets that large, especially not sent more then once every few minutes. If you do for some really wierd reason, though, you can add a check of the packet size first (>250 bytes) then compress it and check if the compression did much of anything (discard the compression if < 10 bytes saved). If it did compress, add a byte to the start of the packet that states it is compressed. |
Author: | William [ Sat Sep 30, 2006 11:45 pm ] |
Post subject: | |
How do you check the size of a packet? |
Author: | Lea [ Sat Sep 30, 2006 11:48 pm ] |
Post subject: | |
Lenb(packet string) returns the number of bytes long |
Author: | Verrigan [ Sun Oct 01, 2006 1:37 am ] |
Post subject: | |
Spodi wrote: Quote: dbytes = StrConv(TmpStr, vbFromUnicode) That is turning your string into a byte array right there. Just for everyone's information... so is this: Code: dbytes = TmpStr
It just doesn't take out the unicode. |
Author: | Obsidian [ Sun Oct 01, 2006 5:13 am ] |
Post subject: | |
you can remove that enigmaencrypt... that was something else i was working on before i sent you that code... |
Page 1 of 4 | All times are UTC |
Powered by phpBB® Forum Software © phpBB Group https://www.phpbb.com/ |