|
Posted by Gordon Burditt on 11/28/05 04:16
>My question is not well stated. Let me try again.
>
>I am working on a php script that will receive database requests from
>remote URL's. The script's job is to execute the request and send the
>results back to the requester.
>
>The requester does the following:
>
>1. Open a connection using fsockopen().
>2. Post headers and request using fputs()
>3. Read response using fgets()
Forget these details. Pretend the situation is: Someone typed the
URL into a browser or clicked on a link. Then do what is appropriate:
output something. Ok, you're outputting xml instead of html. Big
deal. Text is text. When you get a request, it's difficult to
tell that it's *NOT* someone with a browser, and you shouldn't try
to distinguish the difference anyway.
>This works fine. I am using a class that does that in other
>applications communicating with applications that successfully send the
>responses back. I am trying to write a script that also sends responses
>back and that is where I am running into difficulties
>
>The problem script obtains the request from $_POST. That also works.
>The question is how do I send the response back to requester so that it
>can read it using fgets().
Don't even think about trying to establish a connection, the other
end already did it. OUTPUT SOMETHING!! echo. print. printf.
fpassthru. (Maybe you want a header("Content-type: text/xml")
first).
echo "<xml>response</xml>\n";
Note the complete absence of any reference to functions with the
substring "open" or "sock" and the complete absence of handles.
>Or, more specifically, how do I establish a
>connection back to the requester so that I can send the response.
When you receive a telephone call, answer it, and the caller asks
a question, do you need to call him back to send answer? No, you
just *TALK*. It doesn't matter whether the caller is using a VOIP
switch or an old mechanical switchboard and asked the operator to
make the call for him. It doesn't matter whether the call goes
via a satellite. You just talk.
>If I use fsockopen() to establish a connection to the requesting URL,
Do not establish a connection. You've got one established by the
other end. USE IT!
>it appears that it would not be communicating with the same session. I
>also don't see a way to get a handle to the existing connection that
>was created by the requester.
You don't need a handle. OUTPUT SOMETHING!!!
Gordon L. Burditt
Navigation:
[Reply to this message]
|