Re: [xSocket-develop] receiving data from server
Status: Inactive
Brought to you by:
grro
|
From: quan n. h. <hu...@gm...> - 2010-02-25 03:51:10
|
server side is handled by other vendor, i only develop client side to
connect to it.
java doc
int available() throws IOException
the number of available bytes, possibly zero, or -1 if the channel has
reached end-of-stream
-Quan
On Thu, Feb 25, 2010 at 10:44 AM, Erin Drummond <eri...@gm...> wrote:
> I personally havn't tried that, so I dont know if it works. Heres how I do it:
>
> In my case, I have control over the server, so I append the delimiter
> "__DELIMITER__" to the end of each message, then use
> nbc.readBytesByDelimiter("__DELIMITER__") to get the whole message on
> the client side.
>
> It works quite nicely, and results in a bit less code.
>
> On Thu, Feb 25, 2010 at 4:35 PM, quan nguyen huu <hu...@gm...> wrote:
>> i check doc again & found this code
>>
>> private int remaining = 0;
>>
>> ..
>>
>> int available = nbc.available();
>>
>> int lengthToRead = remaining;
>> if (available > remaining) {
>> lengthToRead = available;
>> }
>>
>> byte[] message = nbc.readBytesByLength(lengthToRead);
>>
>> is it the right way?
>>
>> -Quan
>>
>>
>>
>> On Thu, Feb 25, 2010 at 10:10 AM, quan nguyen huu <hu...@gm...> wrote:
>>> hi,
>>>
>>> in client, i use readBytesBylength() to receive data from server:
>>> nbc.readBytesByLength(200);
>>>
>>> but the problem is the message server send to client have different lengths.
>>> example: first, server send 20 bytes message, after server send 7
>>> bytes message to client.
>>> the client always seems to wait for receive full 200 bytes message to
>>> process next step :|
>>>
>>> how to get instant message sent from server.
>>>
>>> thanks
>>> -Quan
>>>
>>
>> ------------------------------------------------------------------------------
>> Download Intel® Parallel Studio Eval
>> Try the new software tools for yourself. Speed compiling, find bugs
>> proactively, and fine-tune applications for parallel performance.
>> See why Intel Parallel Studio got high marks during beta.
>> http://p.sf.net/sfu/intel-sw-dev
>> _______________________________________________
>> xSocket-develop mailing list
>> xSo...@li...
>> https://lists.sourceforge.net/lists/listinfo/xsocket-develop
>>
>
|