• Welcome to Valhalla Legends Archive.
 

another quick question

Started by gotcha_ass, February 25, 2003, 07:30 PM

Previous topic - Next topic

iago

#15
QuoteThat can replace my code?? Would be a lot easier that way. Does it keep the vbCrlf at the end of each string or throw it away?

Throws it away.
This'll make an interesting test for broken AV:
QuoteX5O!P%@AP[4\PZX54(P^)7CC)7}$EICAR-STANDARD-ANTIVIRUS-TEST-FILE!$H+H*


Camel

#16
Quotei = InStr(StringData, vbCrLf) 'find position of first vbcrlf
i = instr(1, stringdata, vbcrlf)

Spht

#17
Quotei = instr(1, stringdata, vbcrlf)

It does the same thing.

gotcha_ass

#18
QuoteDim strLineArray() As String
strLineArray = Split(StringData, vbCrlf)

Now you have a 0-based array containing each line.

Ill just use this then. Thanks Grok

Yoni

#19
Quote     sck.peekdata ph, 4        'peek at the header up to packet length
    sck.getdata ph, ph.length 'now really get it
Bad!

(That is, assuming PeekData does recv with MSG_PEEK)

Camel

#20
gets rid of it

Split("1,2,3,4", ",") would return the same thing as
Array("1", "2", "3", "4")
and just for refrence, join does the opposite:
Join(Array("1", "2", "3", "4"), ",") = "1,2,3,4"

Camel

QuoteBad!

(That is, assuming PeekData does recv with MSG_PEEK)
hrm, didnt think about that...i dont think it does, but just to be safe you could do:
   sck.getdata ph, 4        'peek at the header up to packet length
    sck.getdata ph.data, ph.length - 4 'grab the data

[edit] comments

Yoni

#22
What if you receive under 4 bytes?

Camel

#23
QuoteWhat if you receive under 4 bytes?
*kicks yoni*
sub fucking_dataarrival(totaldata as intetger)
  if totaldata < 4 then exit sub

Banana fanna fo fanna

#24
Quote*kicks yoni*
sub fucking_dataarrival(totaldata as intetger)
  if totaldata < 4 then exit sub

dim buffer as string
dim plen as integer

sub fucking_dataarival(totaldata as integer)
dim d as string
fucking.getdata d

buffer = buffer & d

if len(buffer) >= 4 and plen = 0 then
'get the length
end if

if len(buffer) >= plen
'houston we have a packet
dim packet as string
packet = left(buffer,plen)
buffer = right(buffer,len(buffer)-len(packet))
plen = 0
end if
end sub

Yoni

#25
With Camel's newest code, if you receive between 1 and 3 bytes, they are discarded, causing badly out-of-order packet parsing on the client.

Didn't read through it completely, but Storm's code is probably fine.

Camel

#26
QuoteWith Camel's newest code, if you receive between 1 and 3 bytes, they are discarded, causing badly out-of-order packet parsing on the client.
no they aren't, they stay in the buffer until you read them! i do it all the time!

Yoni

#27
Hmm, alright...
What if you receive an entire packet 1 byte at a time?

dxoigmn

Private Sub Winsock1_DataArrival(ByVal bytesTotal As Long)
bytesTotal is the total number of bytes in the internal buffer.  So even if he does receive 1 byte at a time, then it won't fail.  His code should work fine for BNCS packets.  The only thing I can think of is if he doesn't receive the full BNCS packet content each time.  You would have save the header in a static/global variable and wait until you receive the amount of data the header length says the BNCS packet is.  I believe it is easier to just receive into a buffer, then process packets from that buffer, and not worry about the Winsock's internal buffer.

Edit: added 2 sentences

Mesiah / haiseM

#29
ill go with kamakazie on that one, ive never seen a BNCS packet do that, but data frames are spread out in lots of protocols, and i beleive its best to use your own buffer to do the things you want, for obvious reasons already stated.
]HighBrow Innovations
Coming soon...

AIM Online Status: 

|