xsocket-develop Mailing List for xsocket (Page 4)
Status: Inactive
Brought to you by:
grro
You can subscribe to this list here.
| 2007 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
(12) |
Oct
(9) |
Nov
(11) |
Dec
|
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 2008 |
Jan
(8) |
Feb
(9) |
Mar
(9) |
Apr
(22) |
May
(28) |
Jun
(17) |
Jul
(10) |
Aug
(19) |
Sep
(4) |
Oct
(14) |
Nov
(26) |
Dec
(25) |
| 2009 |
Jan
(13) |
Feb
(17) |
Mar
(12) |
Apr
(4) |
May
(16) |
Jun
(6) |
Jul
(10) |
Aug
(24) |
Sep
(6) |
Oct
(5) |
Nov
(13) |
Dec
(10) |
| 2010 |
Jan
(17) |
Feb
(21) |
Mar
(10) |
Apr
(8) |
May
(2) |
Jun
(14) |
Jul
(7) |
Aug
(10) |
Sep
(7) |
Oct
(3) |
Nov
|
Dec
(2) |
| 2011 |
Jan
(1) |
Feb
(5) |
Mar
(1) |
Apr
|
May
(5) |
Jun
|
Jul
(2) |
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
| 2014 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
(1) |
Oct
(3) |
Nov
|
Dec
|
| 2015 |
Jan
|
Feb
|
Mar
(1) |
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
(1) |
Dec
|
| 2016 |
Jan
|
Feb
|
Mar
|
Apr
|
May
(2) |
Jun
(3) |
Jul
|
Aug
(1) |
Sep
|
Oct
|
Nov
|
Dec
|
| 2019 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
(6) |
Sep
|
Oct
|
Nov
|
Dec
|
| 2020 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
(1) |
|
From: Brad M. <br...@br...> - 2010-04-15 22:50:58
|
Hi Guys, Firstly, I'd like to say what really great technology xsocket is, it makes it very easy to do very cool things :) I'm having a problem getting xsocket to shutdown gracefully. I'm starting the server with ConnectionUtils.start( server ), and when the application is shutdown i'm calling server.close(). But the port continues to be in use so i can't restart my application - even after the java process has gone (which i didnt think was possible). Its very strange. I have to wait between 1 and 5 minutes before the socket becomes free and i can start the application again. This problem only seems to happen on my server which is running linux 2.6.16. There are no other process using that port (confirmed with netstat) Any ideas? Thanks, Brad |
|
From: Gregor R. <gre...@gm...> - 2010-04-15 04:11:21
|
Hi, SSL is supported for the physical connection only. This means running pipelines based on the same physical connection in different mode does not work -> pipeline A plain, pipeline B secured. Please see the code example http://xsocket.svn.sourceforge.net/viewvc/xsocket/xsocket/multiplexed/trunk/src/test/java/org/xsocket/connection/multiplexed/EchoExampleTest.java?view=markup for a secured multiplexed connection. Gregor ----- Original Message ----- From: 李成旭 Sent: 04/15/10 04:49 AM To: xso...@li... Subject: [xSocket-develop] MultiplexedConnection with SSL Really thanks for xSocket. I’m using MultiplexedConnection with SSL. [CLIENT] nonBlockSocket = new NonBlockingConnection(host, port, sslCtx, true); [SERVER] Server tServer = new Server(serverConfig.server_port, adapter, sslCtx, true); I thought my socket channel is already secured. But not. Actually socket send plain text to server (Of course Server also listen secured mode). How can I apply secured channel on MultiplexedConnection. I read mailing-list forum. But couldn’t found about it. Also couldn’t find MultiplxedSocket with ssl sample code and test source. Is it unsupported ? If so, this code should throw exception message. Thnaks. |
|
From: 李成旭 <lee...@nh...> - 2010-04-15 03:10:30
|
Really thanks for xSocket. I’m using MultiplexedConnection with SSL. [CLIENT] nonBlockSocket = new NonBlockingConnection(host, port, sslCtx, true); [SERVER] Server tServer = new Server(serverConfig.server_port, adapter, sslCtx, true); I thought my socket channel is already secured. But not. Actually socket send plain text to server (Of course Server also listen secured mode). How can I apply secured channel on MultiplexedConnection. I read mailing-list forum. But couldn’t found about it. Also couldn’t find MultiplxedSocket with ssl sample code and test source. Is it unsupported ? If so, this code should throw exception message. Thnaks. |
|
From: Gregor R. <gre...@gm...> - 2010-03-23 13:23:32
|
Hi Damien, would you please send some code snippets regarding to this issue or better a JUnit test ;-) Gregor ----- Original Message ----- From: Damien DE SAINT LAURENT Sent: 03/23/10 10:52 AM To: xso...@li... Subject: [xSocket-develop] ExtendedClosedChannelException: could not write. channel is close or not initialized Hi , I would like to use a non blocking client ( I use constructor NonBlockingConnection(host, port) + setHandler ( my Handler that implements IDataHandler and IConnectHandler) but I get this exception org.xsocket.connection.ExtendedClosedChannelException: could not write. channel is close or not initialized at org.xsocket.connection.AbstractNonBlockingStream.ensureStreamIsOpenAndWritable(AbstractNonBlockingStream.java:1539) at org.xsocket.connection.AbstractNonBlockingStream.write(AbstractNonBlockingStream.java:1056) at org.xsocket.connection.AbstractNonBlockingStream.write(AbstractNonBlockingStream.java:1041) at org.xsocket.connection.SynchronizedNonBlockingConnection.write(SynchronizedNonBlockingConnection.java:552) when trying to write a String value on the non blocking connection What did I miss ? Thanks Damien |
|
From: Damien DE S. L. <dde...@si...> - 2010-03-23 09:44:29
|
Hi , I would like to use a non blocking client ( I use constructor NonBlockingConnection(host, port) + setHandler ( my Handler that implements IDataHandler and IConnectHandler) but I get this exception org.xsocket.connection.ExtendedClosedChannelException: could not write. channel is close or not initialized at org.xsocket.connection.AbstractNonBlockingStream.ensureStreamIsOpenAndWritable(AbstractNonBlockingStream.java:1539) at org.xsocket.connection.AbstractNonBlockingStream.write(AbstractNonBlockingStream.java:1056) at org.xsocket.connection.AbstractNonBlockingStream.write(AbstractNonBlockingStream.java:1041) at org.xsocket.connection.SynchronizedNonBlockingConnection.write(SynchronizedNonBlockingConnection.java:552) when trying to write a String value on the non blocking connection What did I miss ? Thanks Damien |
|
From: Gregor R. <gre...@gm...> - 2010-03-12 05:01:31
|
Hello Matt, this is a behaviour of the underlying operation system. TCP defines that closed sockets are transit to TIME WAIT to make sure, that all data was written/received. The duration can be configured on os level. For instance http://publib.boulder.ibm.com/wasce/V1.0.1/en/Tasks/Tuning/Windows.html describes how to do this for windows. You will also find tutorials how to do this for Unix. Gregor ----- Original Message ----- From: Matt Rodatus Sent: 03/11/10 09:06 PM To: xso...@li... Subject: [xSocket-develop] a bunch of TIME_WAIT sockets sitting around Hello, I've begun using xSocket, and I'm thankful for the library -- it is very useful for what we want to accomplish. Our application sends length prefixed strings over sockets. For each connection, the server receives one string and sends one string in response. Then the server closes the connection. I'm using transactional reads on the server, and it's working well -- better than anything else I've tried. However, even though the server does close the connection, a lot of sockets with TIME_WAIT are showing up in netstat -a | grep SERVERPORT after the fact. They disappear after a minute or two, but I'm wondering if there's any way I can get rid of them right away. For example, should I do a blocking closing operation from within the onData method, when I'm done with the connection and want to close it? Obviously, the connection passed to onData is an INonBlockingConnection, so the close operation would also (presumedly) be non-blocking, which I'm guessing may be why the sockets stick around as TIME_WAIT for a bit. Am I anywhere near home base in my diagnosis and proposed solution? If not, what would you suggest? Thanks, Matt ------------------------------------------------------------------------------ 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 |
|
From: Matt R. <ma...@ro...> - 2010-03-11 20:06:36
|
Hello, I've begun using xSocket, and I'm thankful for the library -- it is very useful for what we want to accomplish. Our application sends length prefixed strings over sockets. For each connection, the server receives one string and sends one string in response. Then the server closes the connection. I'm using transactional reads on the server, and it's working well -- better than anything else I've tried. However, even though the server does close the connection, a lot of sockets with TIME_WAIT are showing up in netstat -a | grep SERVERPORT after the fact. They disappear after a minute or two, but I'm wondering if there's any way I can get rid of them right away. For example, should I do a blocking closing operation from within the onData method, when I'm done with the connection and want to close it? Obviously, the connection passed to onData is an INonBlockingConnection, so the close operation would also (presumedly) be non-blocking, which I'm guessing may be why the sockets stick around as TIME_WAIT for a bit. Am I anywhere near home base in my diagnosis and proposed solution? If not, what would you suggest? Thanks, Matt |
|
From: Gregor R. <gre...@gm...> - 2010-03-03 18:18:30
|
Hi Carlo, xSocket is a tcp-level framework. xSocket does not know anything about messages. You can use xSocket to send data to the peer and receive data. xSocket does not define a framing or anything else. This means you have to mark you messages on application level. Gregor ----- Original Message ----- From: Carlo Camerino Sent: 03/01/10 07:16 PM To: xso...@li... Subject: [xSocket-develop] Questions Regarding Multiplexer Clients Hi, I would like to ask if this is possible, I am sending a message to an external tcp/ip server. I'm using one thread to send it and another thread is polling for the reply messages, Is there a possibility for me to be able to correlate the response based on a return message coming from the tcp/ip For example I send two messages Thread 1 Sending --> A010101TRANSACTION Thread 2 Sending --> B020202TRANSACTION-TWO Receiver Thread Getting --> A010101REPLY-TRANSACTION Receiver Thread Getting --> B020202REPLY-TRANSACTION-TWO How can I match this thread based on A010101 --> assuming this is the correlation id that i want to set. How can I make sure that Thread 1 will be the one getting it and not thread 2? I've seen a new pattern called Return Address? How can I implement it with TCP/IP. Does the other end have to be a multiplexer server as well? Thanks Carlo |
|
From: Carlo C. <car...@gm...> - 2010-03-01 18:16:07
|
Hi, I would like to ask if this is possible, I am sending a message to an external tcp/ip server. I'm using one thread to send it and another thread is polling for the reply messages, Is there a possibility for me to be able to correlate the response based on a return message coming from the tcp/ip For example I send two messages Thread 1 Sending --> A010101TRANSACTION Thread 2 Sending --> B020202TRANSACTION-TWO Receiver Thread Getting --> A010101REPLY-TRANSACTION Receiver Thread Getting --> B020202REPLY-TRANSACTION-TWO How can I match this thread based on A010101 --> assuming this is the correlation id that i want to set. How can I make sure that Thread 1 will be the one getting it and not thread 2? I've seen a new pattern called Return Address? How can I implement it with TCP/IP. Does the other end have to be a multiplexer server as well? Thanks Carlo |
|
From: Carlo C. <ca...@sx...> - 2010-03-01 18:10:45
|
Hi, I would like to ask if this is possible, I am sending a message to an external tcp/ip server. I'm using one thread to send it and another thread is polling for the reply messages, Is there a possibility for me to be able to correlate the response based on a return message coming from the tcp/ip For example I send two messages Thread 1 Sending --> A010101TRANSACTION Thread 2 Sending --> B020202TRANSACTION-TWO Receiver Thread Getting --> A010101REPLY-TRANSACTION Receiver Thread Getting --> B020202REPLY-TRANSACTION-TWO How can I match this thread based on A010101 --> assuming this is the correlation id that i want to set. How can I make sure that Thread 1 will be the one getting it and not thread 2? I've seen a new pattern called Return Address? How can I implement it with TCP/IP. Thanks Carlo |
|
From: Gregor R. <gre...@gm...> - 2010-03-01 16:08:44
|
Hi, are you able to reproduce this? by a JUnit class? This behavior will occur, if the receiving peer does not read its network input buffer (fast, 1 min?) enough. Does an related application occur? Gregor ----- Original Message ----- From: ful...@se... Sent: 03/01/10 03:40 AM To: xso...@li... Subject: [xSocket-develop] bug ? Hello, We use xsocket library, and find the following exception, how do you think? is this a bug? java.net.SocketTimeoutException: [c63bb93112717722a2c740347d1C1] send timeout 1min reached. returning from sync flushing (countIsWritten=0, countOnException=0, sendBytes=340851, receivedBytes=30, sendQueueSize=0, countUnknownOnWritten=0, sendQueueSize=0, countIncompleteWrites= sendBytes=340851, reveivedBytes=30, key=OP_WRITE, OP_READ (5) isValid=true, isOpen=true, lastException=null) at org.xsocket.connection.NonBlockingConnection$SynchronWriter.syncWrite(NonBlockingConnection.java:2349) at org.xsocket.connection.NonBlockingConnection.internalFlush(NonBlockingConnection.java:2191) at org.xsocket.connection.NonBlockingConnection.onWriteDataInserted(NonBlockingConnection.java:2034) at org.xsocket.connection.AbstractNonBlockingStream.write(AbstractNonBlockingStream.java:1058) at org.xsocket.connection.AbstractNonBlockingStream.write(AbstractNonBlockingStream.java:1037) ------------------------------------------------------------------------------ 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 |
|
From: Damien DE S. L. <dde...@si...> - 2010-03-01 07:34:42
|
Damien DE SAINT LAURENT Service Informatique Leroy-Merlin France |
|
From: <ful...@se...> - 2010-03-01 03:33:08
|
Hello,
We use xsocket library, and find the following exception, how do you think? is this a bug?
java.net.SocketTimeoutException: [c63bb93112717722a2c740347d1C1] send timeout 1min reached. returning from sync flushing (countIsWritten=0, countOnException=0, sendBytes=340851, receivedBytes=30, sendQueueSize=0, countUnknownOnWritten=0, sendQueueSize=0, countIncompleteWrites= sendBytes=340851, reveivedBytes=30, key=OP_WRITE, OP_READ (5) isValid=true, isOpen=true, lastException=null)
at org.xsocket.connection.NonBlockingConnection$SynchronWriter.syncWrite(NonBlockingConnection.java:2349)
at org.xsocket.connection.NonBlockingConnection.internalFlush(NonBlockingConnection.java:2191)
at org.xsocket.connection.NonBlockingConnection.onWriteDataInserted(NonBlockingConnection.java:2034)
at org.xsocket.connection.AbstractNonBlockingStream.write(AbstractNonBlockingStream.java:1058)
at org.xsocket.connection.AbstractNonBlockingStream.write(AbstractNonBlockingStream.java:1037)
|
|
From: quan n. h. <hu...@gm...> - 2010-02-25 13:57:31
|
thanks
-Quan
On Thu, Feb 25, 2010 at 2:07 PM, Gregor Roth <gre...@gm...> wrote:
> Hi Quoa,
>
> yes the available() method is similar. And I also agree with Erin. You have
> to understand the protocol. Does the protocol use fixed length data records?
> or does it use leading length fileds? or delimiters? or ...?
>
> Gregor
>
>
>
>
> ----- Original Message -----
>
> From: quan nguyen huu
>
> Sent: 02/25/10 05:27 AM
>
> To: Erin Drummond, xso...@li...
>
> Subject: Re: [xSocket-develop] receiving data from server
>
>
>
> in java socket, InputStream.read() return the next byte of data, or -1
> if the end of the stream is reached. I used it to read data of each
> stream.
>
> InputStream in = sock.getInputStream();
>
> byte[] temp = new byte[100];
>
> // receive data
> int length = in.read(temp);
>
> & i think available() method here is similar.
>
> -Quan
>
>
>
> On Thu, Feb 25, 2010 at 10:57 AM, Erin Drummond <eri...@gm...> wrote:
>> In that case, your code seems like it will work if you know in advance
>> how many bytes you need to read. If you dont, I think you will need to
>> look at the protocol used by the vendor to see what denotes an
>> end-of-message and then use readBytesByDelimiter(). I cant think of
>> another way to read a whole message when the length isnt known in
>> advance.
>>
>> Of course I am by no means an expert, Gregor should be able to be more
>> helpful.
>>
>> Cheers,
>> Erin
>>
>> On Thu, Feb 25, 2010 at 4:50 PM, quan nguyen huu <hu...@gm...>
>> wrote:
>>> 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
>>>>>
>>>>
>>>
>>
>
> ------------------------------------------------------------------------------
> 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
>
>
|
|
From: Gregor R. <gre...@gm...> - 2010-02-25 07:08:28
|
Hi Erin,
by setting the option SO_REUSEADDR the socket will be released immediately
Map<String, Object> options = new HashMap<String, Object>();
options.put("SO_REUSEADDR", true);
IServer server = new Server(port, options, myHandler);
// ...
Gregor
----- Original Message -----
From: Erin Drummond
Sent: 02/25/10 04:33 AM
To: xso...@li...
Subject: Re: [xSocket-develop] XSocket not closing underlying OS socket when close() is called
Actually I just discovered that sleeping for a bit after the socket
has been closed seems to fix this. Cheers
On Thu, Feb 25, 2010 at 4:30 PM, Erin Drummond <eri...@gm...> wrote:
> Hi,
>
> I am developing an application using xSocket. During the testing, it
> gets shut down and started up again almost instantly. This makes it
> crash with a "BindException: Address already in use".
>
> It appears as though xSocket does not tell the operating system that
> it has finished with the socket when close() is called. If I wait a
> few minutes, the operating system realises the socket isnt being used
> anymore and closes it, which means I can start my application again
> without it throwing an error.
>
> Is there a solution to this? Here is a test case displaying the behaviour:
>
> import org.junit.Test;
> import org.xsocket.connection.IHandler;
> import org.xsocket.connection.Server;
>
> /**
> * Tests rapid creation and destroying of xSocket sockets
> * Will throw an exception on the 2nd or 3rd iteration
> */
> public class XSocketTest implements IHandler {
>
> @Test
> public void test() throws Exception {
> Server s;
> for (int x = 0; x < 500; x++) {
> s = new Server("localhost", 6789, this);
> s.start();
> Thread.sleep(100); //give it some time to initialise
> s.close();
> }
> }
>
> }
>
> I am using Linux 2.6 (in case this is NIO-related)
>
> Cheers,
> Erin
>
------------------------------------------------------------------------------
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
|
|
From: Gregor R. <gre...@gm...> - 2010-02-25 07:07:41
|
Hi Quoa,
yes the available() method is similar. And I also agree with Erin. You have to understand the protocol. Does the protocol use fixed length data records? or does it use leading length fileds? or delimiters? or ...?
Gregor
----- Original Message -----
From: quan nguyen huu
Sent: 02/25/10 05:27 AM
To: Erin Drummond, xso...@li...
Subject: Re: [xSocket-develop] receiving data from server
in java socket, InputStream.read() return the next byte of data, or -1
if the end of the stream is reached. I used it to read data of each
stream.
InputStream in = sock.getInputStream();
byte[] temp = new byte[100];
// receive data
int length = in.read(temp);
& i think available() method here is similar.
-Quan
On Thu, Feb 25, 2010 at 10:57 AM, Erin Drummond <eri...@gm...> wrote:
> In that case, your code seems like it will work if you know in advance
> how many bytes you need to read. If you dont, I think you will need to
> look at the protocol used by the vendor to see what denotes an
> end-of-message and then use readBytesByDelimiter(). I cant think of
> another way to read a whole message when the length isnt known in
> advance.
>
> Of course I am by no means an expert, Gregor should be able to be more helpful.
>
> Cheers,
> Erin
>
> On Thu, Feb 25, 2010 at 4:50 PM, quan nguyen huu <hu...@gm...> wrote:
>> 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
>>>>
>>>
>>
>
------------------------------------------------------------------------------
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
|
|
From: quan n. h. <hu...@gm...> - 2010-02-25 04:27:38
|
in java socket, InputStream.read() return the next byte of data, or -1
if the end of the stream is reached. I used it to read data of each
stream.
InputStream in = sock.getInputStream();
byte[] temp = new byte[100];
// receive data
int length = in.read(temp);
& i think available() method here is similar.
-Quan
On Thu, Feb 25, 2010 at 10:57 AM, Erin Drummond <eri...@gm...> wrote:
> In that case, your code seems like it will work if you know in advance
> how many bytes you need to read. If you dont, I think you will need to
> look at the protocol used by the vendor to see what denotes an
> end-of-message and then use readBytesByDelimiter(). I cant think of
> another way to read a whole message when the length isnt known in
> advance.
>
> Of course I am by no means an expert, Gregor should be able to be more helpful.
>
> Cheers,
> Erin
>
> On Thu, Feb 25, 2010 at 4:50 PM, quan nguyen huu <hu...@gm...> wrote:
>> 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
>>>>
>>>
>>
>
|
|
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
>>
>
|
|
From: quan n. h. <hu...@gm...> - 2010-02-25 03:36:12
|
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
>
|
|
From: Erin D. <eri...@gm...> - 2010-02-25 03:33:11
|
Actually I just discovered that sleeping for a bit after the socket
has been closed seems to fix this. Cheers
On Thu, Feb 25, 2010 at 4:30 PM, Erin Drummond <eri...@gm...> wrote:
> Hi,
>
> I am developing an application using xSocket. During the testing, it
> gets shut down and started up again almost instantly. This makes it
> crash with a "BindException: Address already in use".
>
> It appears as though xSocket does not tell the operating system that
> it has finished with the socket when close() is called. If I wait a
> few minutes, the operating system realises the socket isnt being used
> anymore and closes it, which means I can start my application again
> without it throwing an error.
>
> Is there a solution to this? Here is a test case displaying the behaviour:
>
> import org.junit.Test;
> import org.xsocket.connection.IHandler;
> import org.xsocket.connection.Server;
>
> /**
> * Tests rapid creation and destroying of xSocket sockets
> * Will throw an exception on the 2nd or 3rd iteration
> */
> public class XSocketTest implements IHandler {
>
> @Test
> public void test() throws Exception {
> Server s;
> for (int x = 0; x < 500; x++) {
> s = new Server("localhost", 6789, this);
> s.start();
> Thread.sleep(100); //give it some time to initialise
> s.close();
> }
> }
>
> }
>
> I am using Linux 2.6 (in case this is NIO-related)
>
> Cheers,
> Erin
>
|
|
From: Erin D. <eri...@gm...> - 2010-02-25 03:30:27
|
Hi,
I am developing an application using xSocket. During the testing, it
gets shut down and started up again almost instantly. This makes it
crash with a "BindException: Address already in use".
It appears as though xSocket does not tell the operating system that
it has finished with the socket when close() is called. If I wait a
few minutes, the operating system realises the socket isnt being used
anymore and closes it, which means I can start my application again
without it throwing an error.
Is there a solution to this? Here is a test case displaying the behaviour:
import org.junit.Test;
import org.xsocket.connection.IHandler;
import org.xsocket.connection.Server;
/**
* Tests rapid creation and destroying of xSocket sockets
* Will throw an exception on the 2nd or 3rd iteration
*/
public class XSocketTest implements IHandler {
@Test
public void test() throws Exception {
Server s;
for (int x = 0; x < 500; x++) {
s = new Server("localhost", 6789, this);
s.start();
Thread.sleep(100); //give it some time to initialise
s.close();
}
}
}
I am using Linux 2.6 (in case this is NIO-related)
Cheers,
Erin
|
|
From: quan n. h. <hu...@gm...> - 2010-02-25 03:10:50
|
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 |
|
From: 王普 <wa...@ho...> - 2010-02-23 09:02:32
|
Client:
import java.io.IOException;
import java.net.InetSocketAddress;
import org.xsocket.connection.BlockingConnection;
import org.xsocket.connection.IBlockingConnection;
public class UserClientTest {
public static void main(String[] args) throws IOException {
InetSocketAddress address = new InetSocketAddress("10.88.132.69", 32111);
IBlockingConnection bc = new BlockingConnection(address.getHostName(),
address.getPort());
String req = "hello";
bc.write(req + "\r\n");
bc.flush();
String s = bc.readStringByDelimiter("\r\n");
System.out.println(s);
}
}
Server-Handler:
public boolean onData(INonBlockingConnection nbc) throws IOException, BufferUnderflowException, ClosedChannelException, MaxReadSizeExceededException {
String data = nbc.readStringByDelimiter("\r\n");
if (data.equals(""))
nbc.write(Constant.RESULT + Constant.FAILURE + "\r\n");
else
nbc.write(Constant.RESULT + Constant.SUCCESS + "\r\n");
nbc.flush();
return true;
}
sometimes ExtendedClosedChannelException wil occur,sometimes not occur.
I am so surprise.
If you can help me, thank you very much! |
|
From: Kevin B. <kev...@go...> - 2010-02-21 17:00:49
|
Hello Gregor, Thanks for your replies, without taxing you any further, is there any good resource(books or website links) where I could get the NIO basics right, I really want to understand how xSocket works, its still all fuzzy to me. Thanks again... Regards, Kevin On 2/21/2010 3:38 PM, Gregor Roth wrote: > > Hi Kevin, > > > the number of (worker) threads is independent of the number of > connection. Thats it what you get by NIO. This enables high scalability. > > > The number of threads depends on you business logic. The call back > methods will be performed by the worker threads. If a worker thread is > still pending in a callback method, a new worker thread will be > created if another call back method (related to another connection) is > called. Often the worker threads return s very fast for the call back > method (However, this depends on your implementation). In this case > you will observe, that only a few worker threads are running. > > > Gregor > > >> ----- Original Message ----- >> >> From: Kevin Boyd >> >> Sent: 02/21/10 09:01 AM >> >> To: Gregor Roth >> >> Subject: Re: [xSocket-develop] production level socket server pitfalls >> >> Hello Gregor, >> Actually I'm not thoroughly conversant with NIO architecture what do >> these internal dispatchers do? >> You say that each open connection allocates system resources and >> memory and also do each running thread. >> >> How does xSocket deal with clients, is each client handled in his own >> thread that means if 100 clients are connected will 100 threads be >> generated. >> Also what are open connections, is 100 clients = 100 open connections. >> >> The OS is Centos 5.2 based on this can I calculate the amount of >> memory that will be used up if 100 clients have active connections >> made to xSocket. >> >> Regards, >> Kevin >> >> >> On 2/20/2010 1:18 PM, Gregor Roth wrote: >>> >>> Hi Kevin, >>> >>> I would suggest setting the timeouts. By default the timeouts are >>> very high. >>> >>> Regarding to the memory, by xSocket uses 2 internal dispatchers by >>> default. By default each dispatcher will preallocate 65536 bytes non >>> direct memory (see system propery >>> org.xsocket.connection.client.readbuffer.preallocation.size). This >>> preallocated buffer will be used to read the network data. Each open >>> connection allocates (OS) system resources and memory. This depends >>> on the OS. Further more each running thread also allocates a >>> predefined amount of memory. This also depends on the OS. >>> >>> Gregor >>> >>> >>>> ----- Original Message ----- >>>> >>>> From: Kevin Boyd >>>> >>>> Sent: 02/19/10 09:47 AM >>>> >>>> To: xso...@li... >>>> >>>> Subject: [xSocket-develop] production level socket server pitfalls >>>> >>>> Hello, >>>> >>>> For a production level socket server what are the potential >>>> pitfalls that I have to consider : >>>> >>>> 1. I have started the server as per the tutorial on the homepage >>>> using >>>> >>>> >>>> IServer srv = new Server(8090, new TestHandler()); >>>> srv.run(); >>>> >>>> 2. The TestHandler class implements the following interfaces >>>> IDataHandler, IConnectHandler, IDisconnectHandler, >>>> IIdleTimeoutHandler, IConnectionTimeoutHandler. >>>> >>>> 3. I haven't set any "System Properties" as yet and >>>> "FlushMode.ASYNC" is not set. >>>> 4. Connection and Idle timeout's are set to default. >>>> >>>> >>>> I have uploaded this to my VPS host. However before letting it >>>> loose in production I wanted to test it for reliability and >>>> scalabity. Any suggestions here would be welcome. >>>> >>>> Memory is another aspect , My VPS host has allotted me 1GB ram with >>>> around 8GB burst capability, is this sufficient. (As of now I have >>>> only 500MB free) >>>> My clients would be continuously connected to the server 24x7, how >>>> much resource would each client connection take up in terms of ram, >>>> if 1000 or more clients would be connected how do I compute the >>>> amount of ram that would be necessary to safely run the socket server. >>>> >>>> Please suggest other points that I have missed out here. >>>> >>>> Regards, >>>> Kevin >>>> >>>> >> |
|
From: Gregor R. <gre...@gm...> - 2010-02-21 10:10:09
|
Hi Kevin,
the number of (worker) threads is independent of the number of connection. Thats it what you get by NIO. This enables high scalability.
The number of threads depends on you business logic. The call back methods will be performed by the worker threads. If a worker thread is still pending in a callback method, a new worker thread will be created if another call back method (related to another connection) is called. Often the worker threads return s very fast for the call back method (However, this depends on your implementation). In this case you will observe, that only a few worker threads are running.
Gregor
----- Original Message -----
From: Kevin Boyd
Sent: 02/21/10 09:01 AM
To: Gregor Roth
Subject: Re: [xSocket-develop] production level socket server pitfalls
Hello Gregor,
Actually I'm not thoroughly conversant with NIO architecture what do these internal dispatchers do?
You say that each open connection allocates system resources and memory and also do each running thread.
How does xSocket deal with clients, is each client handled in his own thread that means if 100 clients are connected will 100 threads be generated.
Also what are open connections, is 100 clients = 100 open connections.
The OS is Centos 5.2 based on this can I calculate the amount of memory that will be used up if 100 clients have active connections made to xSocket.
Regards,
Kevin
On 2/20/2010 1:18 PM, Gregor Roth wrote:
Hi Kevin,
I would suggest setting the timeouts. By default the timeouts are very high.
Regarding to the memory, by xSocket uses 2 internal dispatchers by default. By default each dispatcher will preallocate 65536 bytes non direct memory (see system propery org.xsocket.connection.client.readbuffer.preallocation.size). This preallocated buffer will be used to read the network data. Each open connection allocates (OS) system resources and memory. This depends on the OS. Further more each running thread also allocates a predefined amount of memory. This also depends on the OS.
Gregor
----- Original Message -----
From: Kevin Boyd
Sent: 02/19/10 09:47 AM
To: xso...@li...
Subject: [xSocket-develop] production level socket server pitfalls
Hello,
For a production level socket server what are the potential pitfalls that I have to consider :
I have started the server as per the tutorial on the homepage using
IServer srv = new Server(8090, new TestHandler());
srv.run();
The TestHandler class implements the following interfacesIDataHandler, IConnectHandler, IDisconnectHandler, IIdleTimeoutHandler, IConnectionTimeoutHandler.
*
I haven'tset any "System Properties" as yet and "FlushMode.ASYNC" is not set. *
Connection and Idle timeout'sare set to default.
I have uploaded this to my VPS host. However before letting it loose in production I wanted to test it for reliability and scalabity. Any suggestions here would be welcome.
Memory is another aspect , My VPS host has allotted me 1GB ram with around 8GB burst capability, is this sufficient. (As of now I have only 500MB free)
My clientswould be continuously connected to the server 24x7, how much resource would each client connection take up in terms of ram, if 1000 or more clients would be connected how do I compute the amount of ram that would be necessary to safely run the socket server.
Please suggest other points that I have missed out here.
Regards,
Kevin
|