> My question is, after my inital read from the socket, how do I keep
> polling the socket for the second chunk of data that will come from
> the server?
[ skipping to relevant part of code ]
> // this is where I would need to put some sort of loop in (I think?) to
> keep polling for 90 seconds
[quoted text clipped - 5 lines]
> // ******* end loop?
> baos.close();
As written, the above read loop will read *all* of the data - the
first and second and any additional chunks - send by the server, since
it continues to read until EOF is reached (when the server closes the
connection).
If you want to read the chunks separately, you need to examine the
data to determine when you've reached the end of the first one. Then
to read the second chunk, you simply continue reading from the stream.
The timeout doesn't really change anything. Set a short timeout (1 or
2 seconds perhaps) with Socket.setSoTimeout(). That will to prevent
read() from hanging indefinately if no data is arriving and allow you
to check after each call to read() whether your 90 seconds have
passed.
/gordon

Signature
[ do not email me copies of your followups ]
g o r d o n + n e w s @ b a l d e r 1 3 . s e
jcc - 08 Mar 2006 15:38 GMT
In most cases, the response from server has header Content-Length, so
you know the size of response data to read.
In other cases, please refer
http://www.w3.org/Protocols/rfc2616/rfc2616-sec3.html#sec3.6
http://www.w3.org/Protocols/rfc2616/rfc2616-sec19.html#sec19.4.6
So even your code can read the response data correctly, you still need
to delete the number which identifies the size of each chunk.
Phat Phuq - 08 Mar 2006 16:13 GMT
I'm not getting content length from the server on the initial ack.
I'm doing MIME-based secure EDI as per RFC 3335.
The server is responding with an eof after the initial ack, I need to keep
the socket open and poll the socket for up to 90 seconds until I receive the
MDN (Message Delivery Notification) from the server.
I'm just looking for a simple way to keep looping until I get the second
response.
Thanks.
> In most cases, the response from server has header Content-Length, so
> you know the size of response data to read.
[quoted text clipped - 6 lines]
> So even your code can read the response data correctly, you still need
> to delete the number which identifies the size of each chunk.
Gordon Beaton - 08 Mar 2006 16:18 GMT
> I'm not getting content length from the server on the initial ack.
> I'm doing MIME-based secure EDI as per RFC 3335.
[quoted text clipped - 6 lines]
> I'm just looking for a simple way to keep looping until I get the
> second response.
You have conflicting requirements. If you've really received EOF, the
socket *cannot* be used to receive more data.
/gordon

Signature
[ do not email me copies of your followups ]
g o r d o n + n e w s @ b a l d e r 1 3 . s e
Phat Phuq - 08 Mar 2006 19:59 GMT
I think I've found my answer. It appears that I should be using an
HttpURLConnection and streaming my data through that.
It will allow me to keep querying the server until my message request has
been processed.
I'll go back into my java hole now and start crunching some code. Later...
>> I'm not getting content length from the server on the initial ack.
>> I'm doing MIME-based secure EDI as per RFC 3335.
[quoted text clipped - 11 lines]
>
> /gordon
Phat Phuq - 08 Mar 2006 16:10 GMT
To be more specific about the nature of my post to the server, it is a
transaction request using MIME-based Secure EDI.
The server initally responds with a standard ack (http code 200 if
successful) and then will send a Message Delivery Notification (MDN) as per
RFC 3335. This response can take up to 90 seconds to process on the server.
And yes, I do receive an eof before this second transmission from the
server.
So what I'm trying to achieve is some sort of polling loop (I'm not
concerned about efficiency right now, I just need to get it to work) so I
can read all the data and dump it to a file for processing.
>> My question is, after my inital read from the socket, how do I keep
>> polling the socket for the second chunk of data that will come from
[quoted text clipped - 29 lines]
>
> /gordon