How would the compiler know that a string was in the pipeline without parsing virtually everything all the time, which would be a major slowdown? I suspect this could be the reason it isn't there. If you as programmer know that what's coming is a string, based on header info you prefixed it with, etc. you can just PeekS() at it. It doesn't add much difficulty to our task imho and it keeps things running full speed.
@Netmaestro: Hmmm the problem is maybe more complex than I have been thinking. I would have to peekS the length of the buffer. The problem I have been having is that what gets sent looks (as the server sees it as "DO this TO that WHERE this = SOMETHING;DO this TO that WHERE this = SOMETHING;" and so the query has more than 1 ";" in it
So it does not parse correctly.
I mean to send "DO this TO that WHERE this = SOMETHING;" and a second "DO this TO that WHERE this = SOMETHING;" (and possibly a third etc.)
The only way I can do this now is to force a delay of at least Delay(878) between each SendNetworkString() event...
I am trying to build an internal parser into the SQL Server. I haven't reasoned it out yet.
Rook Zimbabwe wrote:The only way I can do this now is to force a delay of at least Delay(878) between each SendNetworkString() event...
You could send a zero byte after each string to force a end to the received string - you'd need to check the length of the string vs the buffer size in case of multiple strings being sent though, and parse the result, but that's easy enough to do...
there is no sig, only zuul (and the following disclaimer)
I know this is your feature request and not a request for solutions, so forgive this post.
What exactly is happening at the receive end? You are losing some data? Getting mangled data? Or not getting any at all (data that is, with the other you will need to seek help elsewhere!)?
I am assuming you get some data, not all, or all data but mangled in some way.
Also (assuming you control both ends of the deal) you can structure the outgoing data in any way you want and reassemble it on the incoming side. So if you can provide an eg of what you are sending (not code, just data) perhaps we can work out a methodology that fixes the prob.
Ignore this post if it is (a) out of line (b) out of context (c) out of date or (d) I am out of my mind.
I have a routine called SendNetworkDataEx and ReceiveNetworkDataEx, but the ReceiveNetworkDataEx throws an event with the data once it has received everything and it is all valid.
I'm using to send and receive variable length XML files for use with my RPC toolkit.
Would this be of any use? If so, I'll post it up to the Tips and Tricks section later.
There used to be a ReceiveNetworkString() function and a corresponding event,
but the problem was that it cannot be reliably decided when some random data
is a string and when its not. Thats why it was removed.
> I mean to send "DO this TO that WHERE this = SOMETHING;" and a second "DO this TO that WHERE this = SOMETHING;" (and possibly a third etc.)
> The only way I can do this now is to force a delay of at least Delay(878) between each SendNetworkString() event...
You cannot expect to be receiving the data in the same chunk sizes as you sent it.
The data is sent as a stream, so there is no way of telling the chunk sizes at the other end.
A Delay() will not help, as a very slow network connection could still cause the first part
to be delayed so much that both arrive at the same time on the target.
You have to be prepared to receive the data in any chunk sizes, both larger or
smaller than what you originially sent.
I would appreciate having a ReceiveNetworkString() as well. I think it is not that problematic. I did something similar for myself. It is not a matter whether or not we are dealing with binary or string data. The programmer decides. If he uses ReceiveNetworkString(), string data will be expected. The function must look for the next #CRLF$ line feed in the data buffer and returns the data as a string. If there is no more data in the buffer, the function must block until new data received. But you have to take care that even a #CRLF$ can be split!