Re: [xSocket-develop] nbc and reading incomming frames with bytes
Status: Inactive
Brought to you by:
grro
|
From: Gregor R. <gre...@go...> - 2008-12-01 15:32:06
|
Hi sly,
the method connection.available() return the available bytes. Typically you
will read all available like this:
//////////////////////
//
public boolean onData(INonBlockingConnection connection)
int available = connection.available();
if (available > 0) {
ByteBuffer[] data = connection.readByteBufferByLength(available);
// ...
return true;
} if (available == -1) {
// connection is closed
// ...
return true;
}
}
//
////////////////////////////////
If available returns -1 the end of stream is reached.
Gregor
2008/12/1 <jun...@wp...>
> hi,
>
> What method should I use to read whole data field of incoming Ethernet
> frame? I tried readByteBufferByDelimiter but I'm not sure how to specify
> delimiter. I want to read all bytes in data field. How to set delimiter
> to read data until there is no more data?
>
> ByteBuffer[] res2 = nbc.readByteBufferByDelimiter("");
> System.out.println(res2);
>
> regards,
> sly
>
> ----------------------------------------------------
> Pstryk i klik.
> Na Pikeo.pl szybko zamieszczasz swoje najlepsze zdjęcia:
>
> http://klik.wp.pl/?adr=http%3A%2F%2Fpikeo.pl%2Finstances%2Fwp%2Fstrona_01.jsp&sid=557
>
>
>
> -------------------------------------------------------------------------
> This SF.Net email is sponsored by the Moblin Your Move Developer's
> challenge
> Build the coolest Linux based applications with Moblin SDK & win great
> prizes
> Grand prize is a trip for two to an Open Source event anywhere in the world
> http://moblin-contest.org/redirect.php?banner_id=100&url=/
> _______________________________________________
> xSocket-develop mailing list
> xSo...@li...
> https://lists.sourceforge.net/lists/listinfo/xsocket-develop
> |