hello everyone.. i am stuck with sending packets.. here is my protocol

1st packet DWORD cmd
2nd Packet DWORD cmd1
3rd Packet DWORD cmd2

for example
cmd db "1",0
cmd1 db "Caption",0
cmd2 db "Message",0


now, if i send this to the remote server, it should display a message box like this:

;i need to split the packet in 3 parts
;cmd,cmd1,cmd2 and continue:

invoke atodw,addr cmd
if eax == 1
invoke MessageBox,hWin,addr cmd2,addr cmd1,MB_OK
.endif

So how can i do that? thanks a lot :D
Posted on 2002-07-08 12:48:47 by Tsongkie[ii]
Well it looks like your sending 3 strings so the server isn't going to know how much to expect. Why don't you just send them as DWORDS and not as text
Command1 dd 1
Command2 dd 2
etc

And then you could always use dwtoa to if you wanted to dsiplay the value somewhere

Wait I didn't quite Get What your doing. If you need to send some text that you want to be diplayed in a message box then the server could read in data to a temp buffer untill it reaches a zero byte and then pass that buffer to the MessageBox function.
Posted on 2002-07-08 12:58:21 by Kudos
i would construct the packet like this, and send it as one:
-------------------------------------
|cmd|len cmd1|cmd1|len cmd2|cmd2|
-------------------------------------
Posted on 2002-07-08 13:18:35 by savage

i would construct the packet like this, and send it as one:
-------------------------------------
|cmd|len cmd1|cmd1|len cmd2|cmd2|
-------------------------------------


can you give me a little code? im quite new at this
Posted on 2002-07-08 13:32:18 by Tsongkie[ii]
you construct the packet something like this (pseudocode):
buffer db 100 dup (0)

cmd db "1",0
cmd1 db "Caption",0
cmd2 db "Message",0

lea esi, buffer
mov al, byte ptr [cmd]
mov byte ptr [esi], al
invoke lstrlen, addr cmd1
mov byte ptr [esi+1], al
invoke lstrcat, esi, addr cmd1
invoke lstrlen, esi
add esi, eax
invoke lstrlen, addr cmd2
mov byte ptr [esi], al
invoke lstrcat, esi, addr cmd2

and then send the buffer.

when received, read off the first byte.
which controls the cmd type
read the second byte, which is the length of your 2nd parameter.
copy all the chars to a buffer since you know the length
and do the same for the second command.


invoke recv, hsock, addr buffer, buffer_recv_size, 0

lea esi, buffer

movzx eax, byte ptr [esi] ;get command type
mov cmdtype, eax

inc esi ;esi now points to cmd1 length

movzx eax, byte ptr [esi] ;get cmd1 length
push eax ;save cmd1 length
invoke MemCopy, [esi+1], addr cmd1, eax ;copy cmd1

pop eax ;load cmd1 length
add esi, eax ;esi now points to cmd2 length
movzx eax, byte ptr [esi] ;get cmd2 length
invoke MemCopy, [esi+1], addr cmd2, eax ;copy cmd2


not the best and optimized code and prolly has some errors in it, but it's about the idea :)
Posted on 2002-07-08 13:49:38 by savage
thank you vey much. im going to try it out now :D
Posted on 2002-07-09 09:40:01 by Tsongkie[ii]