That's partially right, the -1 is only thrown if the socket is closed.
If that socket is used more than once, than you cannot choose this method.

Maybe I misunderstood the question of [EMAIL PROTECTED]

:-)
Markus

Vikas schrieb:
> Hi markus,
> 
>     we can detect end of stream like ...
> 
>         ServerSocketConnection server;
>         SocketConnection conn;
>         DataInputStream response = null;
>         try {
>            // get the incoming connection
>            server = (ServerSocketConnection) Connector.open( clientURL );
>            conn = (SocketConnection) server.acceptAndOpen();
>            response = new DataInputStream(conn.openInputStream());
>            int ch=0;
>            while ((ch=response.read()) !=-1 ){
>             System.out.print((char)ch);
>        }
> 
> Might this will help you.
> 
> With best regards
> From
> Vikas R. Khengare
> 
> ----- Original Message ----- 
> From: "Markus Sinner" <[EMAIL PROTECTED]>
> To: <[email protected]>
> Sent: Wednesday, October 17, 2007 10:08 PM
> Subject: Re: [Eclipseme-users] reading of a socket
> 
> 
>> A Socket-Operation always blocks, so you have to ensure that you know,
>> when the data ends. Your Server-Side should send the length of the
>> response first, and then the data. That's what i do when using
>> TCP-Sockets. The SocketConnection is a Stream, and therefore normally
>> has no "end".
>>
>> So try sending an int first, which specifies how many bytes will fallow.
>>
>> Markus
>>
>> [EMAIL PROTECTED] schrieb:
>>> hey !
>>>
>>> i try to read all the data of an open socket. but i am not able to get
> all the data till the end.
>>> can somebody help me ?
>>>
>>> my code :
>>>
>>> SocketConnection socketConnection = (SocketConnection)
> serverSocketConnection.acceptAndOpen();
>>> OutputStream out = socketConnection.openOutputStream();
>>> InputStream in = socketConnection.openInputStream();
>>>
>>> int bytesRead = 0;
>>> byte[] buffer = new byte[5];
>>> String data = "";
>>>
>>> while((bytesRead = in.read(buffer)) != 0){
>>>     data += new String(buffer);
>>> }
>>>
>>> System.out.println(data);
>>>
>>> i am not getting to the end of the stream.
>>>
>>> thx for helping !
>>>
>> -------------------------------------------------------------------------
>>> This SF.net email is sponsored by: Splunk Inc.
>>> Still grepping through log files to find problems?  Stop.
>>> Now Search log events and configuration files using AJAX and a browser.
>>> Download your FREE copy of Splunk now >> http://get.splunk.com/
>>> _______________________________________________
>>> Eclipseme-users mailing list
>>> [email protected]
>>> https://lists.sourceforge.net/lists/listinfo/eclipseme-users
>>>
>> -------------------------------------------------------------------------
>> This SF.net email is sponsored by: Splunk Inc.
>> Still grepping through log files to find problems?  Stop.
>> Now Search log events and configuration files using AJAX and a browser.
>> Download your FREE copy of Splunk now >> http://get.splunk.com/
>> _______________________________________________
>> Eclipseme-users mailing list
>> [email protected]
>> https://lists.sourceforge.net/lists/listinfo/eclipseme-users
> 

-- 

*********************************
[EMAIL PROTECTED]
http://www.psitronic.de

psitronic IT-Solutions
Markus Sinner
W-Rathenau-Str. 14 - 68642 Bürstadt
Tel.: (+49)6206 / 963513
Fax:  (+49)6206 / 963514

-------------------------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems?  Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now >> http://get.splunk.com/
_______________________________________________
Eclipseme-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/eclipseme-users

Reply via email to