in reply to more zero byte madness

I don't mean to ask a stupid question, but your code above is consistent with the output you're wanting. $data should be sent to the client followed by a null byte. My question is this: Are you certain $data has the value you expect? Are you certain that the client is getting an empty message (a single null byte)?

Replies are listed 'Best First'.
Re: Re: more zero byte madness
by chorg (Monk) on Dec 05, 2000 at 20:30 UTC
    Well, in a word, yes. Here's what I've done to verify the output.

    I've stepped through the code using the debugger and seen the actual output string.generated.

    I've telneted into the server, typed in an appropriate request and recieved from the server the appropriate response as well.
    _______________________________________________
    "Intelligence is a tool used achieve goals, however goals are not always chosen wisely..."

      Perhaps there is a buffering issue here? What you're describing isn't quite consistent with that, so if that's the case, something isn't quite as you say it is.

      If you want to be doubly certain it's not your client and it's not your network, use something like ngrep to verify the contents of the message. Verify that the entire command is in the message and that it is terminated with a null byte. I cannot imagine that this is not the case.

      On the server side, be sure you aren't doing something like while (<$client>) { ... } (without setting $/). Since you're dealing with a binary protocol, it's better in my experience that you use something like sysread to read data, and subsequently chop that data up into discrete commands. You may also have success setting $/ to "\0" and try reading "lines" like above.

      If this is a buffering issue, though, I don't know why the server would see \0 but would not see the contents of the command. That just doesn't make any sense to me. With the information you've given us, I don't see how that is possible. Something isn't right.

        Sorry, perhaps I have not been clear enough. My server gets the data just fine. It is null terminated ASCII, that it gets. The server processes it just fine. When I go to print to the socket, I do this:

        local $\ ="\0"; print $sock $xml;
        and I hope to get that to the application. The application is not getting it however. It seems to recognize that something did arrive, but it seems to think that it's null.

        The client application is Flash 5 by the way, if I did not mention that before. It claims to be able to establish a tcp/ip socket connection to a server (which it can) and then get xml from the result (which is the problem). Any tips at all?
        _______________________________________________
        "Intelligence is a tool used achieve goals, however goals are not always chosen wisely..."