Using Nio with sslsockets

hi
how can i use in the nio packeage the sslsockets

By using JDK 1.5, there is a class SSLEngine that applies SSL to an arbitrary transport, so you can use it with NIO. Unless you really need NIO, I suspect you are asking for trouble. NIO was quite unstable in 1.4, changing from versionto version as they fixed bugs. I suspect SSLEngine will be similar.

Similar Messages

  • Question on use of NIO with je

    I saw the FAQ entry about NIO: http://www.oracle.com/technology/products/berkeley-db/faq/je_faq.html#24
    Could you clarify the problems with NIO and situations it shouldn't be used? Currently we are using it with 3.2 and haven't run into any issues but I don't know if we are just getting lucky.
    -Nick

    What I recall is that the NIO JVM bugs were related to GC. Direct memory is not managed like ordinary heap memory, so a separate (and buggy) mechanism is used in the JVM. The symptoms were very slow GC and OOME. It's possible that Sun has fixed these problems since then, but as Charles said there is no measurable performance benefit for direct memory in JE, so it is no longer used in JE. As Charles says, ByteBuffers are still used, but this is not a use of direct memory.
    --mark                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   

  • Using nio And udp

    My first question is. If my server is using nio datagramchanels, my client must use it too?
    can i use traditional datagram socket for comunicate with a nio udp server?
    I have much information on nio and tcp with examples that work. but i can't find examples of communication between client and server using nio UDP. Some page of reference or tutorial?

    My first question is. If my server is using nio
    datagramchanels, my client must use it too?No.
    can i use traditional datagram socket for comunicate
    with a nio udp server?Yes.
    I have much information on nio and tcp with examples
    that work. but i can't find examples of
    communication between client and server using nio
    UDP. Some page of reference or tutorial?You haven't looked very hard. Try 'NIO UDP example' on google.

  • Anyone use nio-memory-manager ?? what's it good for?

    Can someone give me an example of when the nio-memory-manager should be used?
    Thanks,
    Andrew

    If I remember the outcome of my experiments with NIO right the situation is as follows:
    1. Allocating/releasing huge shared memory blocks over and over can lead to OS/JVM issues. To avoid this I allocated the max size I wanted from the start (this is an option when configuring "off-heap" storage I believe). When doing it this way I had no reliability issues with the NIO memory manager in my tests.
    2. Tangosol/Oracle used to claim that the off-heap (NIO memory manager) result in worse performance than on-heap - I could not see any clear indication of this but this may be application dependent. For our app the reduced number of JVM:s per server (reducing network communication, number of threads, risk of any JVM performing GC at a given time etc etc) seemed to more than offset the allegedly slower memory manager resulting in MUCH BETTER performance! A lot of queries etc anyhow (at least for us) mainly work against indexes that always are stored "on-heap"...
    3. There is a limitation to 2Gb per NIO block (at least in 32-bit JVM:s not sure about 64:bit - never seen any point in using them since larger heaps than 2Gb seldom work well anyhow and each pointer consumes double the space in heap and CPU-caches) but this is for each CACHE and separate for PRIMARY and BACKUP I believe! So my understanding is that if you (using 64-bit OS) for instance have two (equally big) caches you could allocate max 2 * 2 * 2 = 8Gb of off-heap memory for folding data per JVM (without ANY impact on GC-pauses!) and in addition to that use as much heap as you can get away with (given GC-pause times) for holding the indexes to that data. This would makes a huge difference in JVM count!- for example we today have to run like 10+ JVM:s per server using "on-heap" while we using "off-heap" storage probably could get that down to one or two JVM:s per server!
    4. There may be both OS and JVM parameter that you need to set (depending on OS and JVM used!) in order to allocate large amounts of shared memory using NIO (the default is rather small).
    As for the question about de-allocation I never saw any sign of memory leaks with the NIO memory manager (i.e. space previously occupied by deleted objects were reused for new objects) but as I mentioned above you better allocating the max size NIO memory block you intend to use up-front and that memory will then remain allocated for this use so if your amount of cache data vary and you would like to use memory for other purposes (like heap!) at some point you may be better of sticking with "on-heap" that is more flexible in that respect.
    As I previously mentioned off-heap is today (until Oracle fixes the improvement request!) really only an option if you do not plan to use "overflow protection" or your objects are fixed size :-(
    And if you are interested in using servers with a lot of memory and would like to use "off-heap" please talk to your Oracle sales rep about it! If enough people do that it may allow the Coherence developers to assign more time for making "off-heap" storage better! With this feature in place Coherence will be even more of a "killer application" than it already is!
    Best Regards
    Magnus

  • GZIP using nio ByteBuffer

    In Java 1.4 CharsetEncoder/CharsetDecoder classes were added to encode/decode unicode to/from ByteBuffers to fully utilize the performance advantages of the nio package. Why didn't they do the same for GZIP compresssion/decompression? Does anyone know of a way to read/write a GZIP file using nio and compress/decompress to/from ByteBuffers instead of using GZIPInputStream and GZIPOutputStream?

    llschumacher wrote:
    That will work but it is not what I had in mind. I wish to offload compression/decompression to another thread. Basically what I am doing is reading byte buffers with one thread, queueing them to a second thread to decompress and then queueing the decompressed buffer to a third thread for Unicode Decoding. I also want to use 3 threads in reverse order to perform writes. I can do this with Unicode encode/decode using CharsetEncoder/CharsetDecoder classes because they deal directly with ByteBuffers. Your solution would require me to use the same thread for IO and compress/decompress.here you go...
    1) create a threadpool executor.
    2) inherit from and extend callables to read or write nio channel objects
    3) use Inflate/Deflate on byte[] for your needs.
    4) works for JCE code as well

  • Sockets using NIO

    Hi all,
    I have a design question regarding socket architecture.
    I have written a server where there are certain services running. this is actually a socket server.
    Now i am writing a client.
    The challenge is the clients are many applets in one jsp page and all of them will essentially use one connection that is established to the server.
    So either we can make a basic applet which all others applets extend and use it.
    Can someone help with the code in java socket/nio to use and implement this kind of architecture?

    If the server uses NIO, there is not requirement for the client to do the same.
    Sharing code does not mean they will share the same connection, only that they will do it the same way. I would suggest you get it to work with individual connections and then optimise it to use a single connection.

  • Please help: data doesn't get through when using NIO's UDP

    Hi there, I have a 2D client-server game, using NIO's UDP. Whenever the clients send data to server, the data just disappears and not exception nor error appear at the server side.
    Following are the portions of the code where the problem occurs, please help me have a look, many thanks.
    (Please note, I'm using non blocking mode for both client and server, and have no problems with other portions of code, communication was fine, data did get through the network and processed by the server/client. Also, client's DatagramChannel "dChannel" is connected to server, however server's DatagramChannel is not connected to any one).
    //***client's sending code***
    public void sendEventToServer(int[] values) {
        prepWriteBuffer(values);
        try {
          dChannel.write(writeBuffer);
        catch (Exception ioe1) {
          System.out.println("Error when send event to server");
    public void prepWriteBuffer(int[] values) {
        writeBuffer.clear();
        writeBuffer = ByteBuffer.allocate(128);
        if (values[0] == 1) { //fire event
          writeBuffer.putInt(0, firePacketNum);
          firePacketNum++;
        else if (values[0] == 2) { //positional event
          writeBuffer.putInt(0, positionalPacketNum);
          positionalPacketNum++;
        else {
          writeBuffer.putInt(0, -1);
        int j = 4;
        for (int i = 0; i < values.length; i++) {
          writeBuffer.putInt(j, values);
    j += 4;
    writeBuffer.flip();
    //***server's code*****
    public void sReceive(long startTime){
        do {
          readBuffer.clear();   //note, readBuffer is 3072 bytes, bigger than client's sending buffer
          InetSocketAddress sourceAddr = null;
          // read from the channel into our buffer
          try {
                 sourceAddr = (InetSocketAddress) dChannel.receive(readBuffer);
          catch (Exception ioe) {
                 System.out.println(ioe);
          // check for end-of-stream
          //I tried with "if (readBuffer.hasRemaining())", getting the same "data disappearing" problem
          if (sourceAddr == null) {
                 //*********Problem: no matter how often the client is sending, this "if" clause is always entered
                 //that is, data disappeared
                 System.out.println("Server got nothing so breaks.");
                 break;
          else {
                 //******Problem: client keeps sending, but this "else" is never entered.
                 System.out.println("Server now got someting from client.");
                 readBuffer.flip();
                 broadcastEvent(readBuffer, sourceAddr);
        while ((System.currentTimeMillis() - startTime) < 134);

    Here's how the buffer filling stuff works, Ron Hitchen's JAva NIO O'Reilly press, has lots of good diagrams of this.
    buf = ByteBuffer.allocate(10)  // creates new buffer
      0----1----2----3----4----5----6----7----8----9----10
      |    |    |    |    |    |    |    |    |    |    |
      ----------------------------------------+
      ^                                                 ^
      |                                                 |
    position=0                                       limit=capacity
    buf.putInt(5);  // relative put, updates position
      0----1----2----3----4----5----6----7----8----9----10
      | 00 | 00 | 00 | 05 |    |    |    |    |    |    |
      ----------------------------------------+
                          ^                             ^
                          |                             |
                       position=4                    limit=capacity
                       updated
    buf.putInt(4,12);  // absolute put doesn't update position
      0----1----2----3----4----5----6----7----8----9----10
      | 00 | 00 | 00 | 05 | 00 | 00 | 00 | 0c |    |    |
      ----------------------------------------+
                          ^                             ^
                          |                             |
                       position=4                     limit=capacity
    buf.position(8);  // so we set the position ourselves
      0----1----2----3----4----5----6----7----8----9----10
      | 00 | 00 | 00 | 05 | 00 | 00 | 00 | 0c |    |    |
      ----------------------------------------+
                                              ^         ^
                                              |         |
                                         position=8   limit=capacity
    buf.flip();  // flip prepares for write
      0----1----2----3----4----5----6----7----8----9----10
      | 00 | 00 | 00 | 05 | 00 | 00 | 00 | 0c |    |    |
      ----------------------------------------+
      ^                                       ^         ^
      |                                       |         |
    position=0                             limit=8   capacity
    channel.write(buf); // write it out, assume all gets written
      0----1----2----3----4----5----6----7----8----9----10
      | 00 | 00 | 00 | 05 | 00 | 00 | 00 | 0c |    |    |
      ----------------------------------------+
                                              ^         ^
                                              |         |
                                  position=limit=8   capacity
    if it didn't all go out, the position would indicate the
    first unwritten byte.

  • HT202667 Hi - My daughter was using her Apple TV until recently when she got a Smart TV.  Now the Apple TV is not needed so she passed it on to me.  How do I get it transferred over from her Home Sharing account to mine so that I can use it with my PC?

    Hi - My daughter was using her Apple TV until recently when she got a Smart TV.  Now the Apple TV is not needed so she passed it on to me.  How do I get her Home Sharing account transferred over to mine so that I can use it with my PC? Thanks!

    As  Winston Churchill wrote, however you might want to do a factory reset on the Apple TV.
    This way all information pertaining to your daughter will be removed from the device. Specifically if see was sign into any of the streaming service, Netflix, Hulu, etc. her credentials will still be associated with this Apple TV, doing  a factory reset will remove all that and make it as if you purchased the device and just plugged it in.
    regards

  • OPEN CURSOR using a WITH clause in the select query

    Hi,
    I am using Oracle 9i. I have a requirement where I have a REFCURSOR as an OUT parameter for my procedure. I have declared the TYPE and created the procedure.
    In the procedure, I am using OPEN <cursor_name> FOR <query>;
    Ideally this works in most of the cases that I have tried earlier. However, in the current case I am using a WITH clause in my query to get the results.
    I need help in understanding if the above mentioned syntax would not allow me to use the WITH clause in the query.

    What error do you get , seems to work ok for me on 10g
    SQL> begin
      2  open :cv for 'with x as (select * from emp)  select * from x';
      3  end;
      4  /
    PL/SQL procedure successfully completed.
    SQL> print :cv
         EMPNO
    ENAME
    JOB              MGR HIREDATE         SAL       COMM     DEPTNO
          7521
    WARD
    SALESMAN        7698 22-FEB-81       1250        500         30
          7566
    JONES
    MANAGER         7839 02-APR-81       2975                    20
         EMPNO

  • My iPhone 4 will not sync my new voice memos from the "Voice Memos" app to my computer. This is frustrating, should not be so hard, can someone please help. I use PC with windows 7 with iPhone version 6.1.3 and iTunes most recent. Thanks.

    My iPhone 4 will not sync my new voice memos from the "Voice Memos" app to my computer. This is frustrating, should not be so hard, can someone please help. I use PC with windows 7 with iPhone version 6.1.3 and iTunes most recent. Thanks.

    In the Music tab of iTunes, do you have 'Include Voice Memos' checked?

  • I ordered my Macbook Air with Aperture two years ago. I now have an iMac - can I use that with Aperture in any way?

    I ordered my Macbook Air with Aperture two years ago. I now have an iMac - can I use that with Aperture in any way? I appreciate that it is a different computer but I am now the end user of both devices and I was just wondering if it was possible.
    Thanks,
    Sean

    The answer would be in your software license agreement for Aperture. However if you cannot locate it you can ask in the Aperture forum, the link for that is:
    https://discussions.apple.com/community/professional_applications/aperture
    However I believe you can have Aperture installed on two machines however only one may be using it at a time.
    On the new iMac launch the Mac App Store - Purchased - look for Aperture and download to your new machine.

  • How do I use LDAP with iMQ 2.0?

    I am looking for an example to see how to use LDAP with iMQ 2.0.
    I was able to set up the config settings to access a local LDAP,
    but iMQ authentication still rejects valid logins.
    Let me know if I can find more info someplace.

    You can also find an example I put togther in the Sun One knowledge base.
    If you go here:
    http://knowledgebase.iplanet.com/NASApp/ikb/index.jsp
    Search for article 7772
    Alternatively here is the direct link
    http://knowledgebase.iplanet.com/ikb/kb/articles/7772.html

  • How do you use Struts with Jboss Portal

    I am trying to use strust with jboss portal but I am getting the following error:
    An error occured while rendering window 'default.MyPortlet2.myportlet2Window'
    org.apache.jasper.JasperException: Exception in JSP: /WEB-INF/jsp/SearchResultPage.jsp:71 68: List searchresult = (List) request.getAttribute("searchresult"); 69: %> 70: Stacktrace:
    I am getting this is in the log file
    Caused by: org.apache.jasper.JasperException: Exception in JSP: /WEB-INF/jsp/SearchResultPage.jsp:71
    68: List searchresult = (List) request.getAttribute("searchresult");
    69: %>
    70: <%
    71: for (Iterator itr=searchresult.iterator(); itr.hasNext(); )
    72: {
    73: testPackage.net.dao.hibernate.WorkList workList = (testPackage.net.dao.hibernate.WorkList)itr.next();
    74: %>
    Stacktrace:
    at org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:504)
    at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:393)
    at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:314)
    at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:264)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:810)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:252)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
    at org.jboss.portal.portlet.impl.jsr168.PortletRequestDispatcherImpl.execute(PortletRequestDispatcherImpl.ja
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:585)
    at org.jboss.portal.server.servlet.CommandFilter.doFilter(CommandFilter.java:65)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
    at org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:672)
    at org.apache.catalina.core.ApplicationDispatcher.doInclude(ApplicationDispatcher.java:574)
    at org.apache.catalina.core.ApplicationDispatcher.include(ApplicationDispatcher.java:499)
    at org.jboss.portal.portlet.impl.jsr168.PortletRequestDispatcherImpl.include(PortletRequestDispatcherImpl.ja
    ... 238 more
    Caused by: java.lang.NullPointerException
    at org.apache.jsp.WEB_002dINF.jsp.SearchResultPage_jsp._jspService(SearchResultPage_jsp.java:152)
    at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:97)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:810)
    at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:332)
    ... 255 more

    I am trying to use strust with jboss portal but I am getting the following error:
    An error occured while rendering window 'default.MyPortlet2.myportlet2Window'
    org.apache.jasper.JasperException: Exception in JSP: /WEB-INF/jsp/SearchResultPage.jsp:71 68: List searchresult = (List) request.getAttribute("searchresult"); 69: %> 70: Stacktrace:
    I am getting this is in the log file
    Caused by: org.apache.jasper.JasperException: Exception in JSP: /WEB-INF/jsp/SearchResultPage.jsp:71
    68: List searchresult = (List) request.getAttribute("searchresult");
    69: %>
    70: <%
    71: for (Iterator itr=searchresult.iterator(); itr.hasNext(); )
    72: {
    73: testPackage.net.dao.hibernate.WorkList workList = (testPackage.net.dao.hibernate.WorkList)itr.next();
    74: %>
    Stacktrace:
    at org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:504)
    at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:393)
    at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:314)
    at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:264)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:810)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:252)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
    at org.jboss.portal.portlet.impl.jsr168.PortletRequestDispatcherImpl.execute(PortletRequestDispatcherImpl.ja
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:585)
    at org.jboss.portal.server.servlet.CommandFilter.doFilter(CommandFilter.java:65)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
    at org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:672)
    at org.apache.catalina.core.ApplicationDispatcher.doInclude(ApplicationDispatcher.java:574)
    at org.apache.catalina.core.ApplicationDispatcher.include(ApplicationDispatcher.java:499)
    at org.jboss.portal.portlet.impl.jsr168.PortletRequestDispatcherImpl.include(PortletRequestDispatcherImpl.ja
    ... 238 more
    Caused by: java.lang.NullPointerException
    at org.apache.jsp.WEB_002dINF.jsp.SearchResultPage_jsp._jspService(SearchResultPage_jsp.java:152)
    at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:97)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:810)
    at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:332)
    ... 255 more

  • How do I use my apple bluetooth keyboard with touch and will I still be able to use it with my ipad?

    How do I use my apple bluetooth keyboard with touch and will I still be able to use it with my ipad?

    iPod touch User Guide (For iOS 4.3 Software)

  • How do I use user_datastore with a feeder proc to add an mdata section?

    Hi,
    I have text data spread across a number of different tables. I have created a user_datastore with a feeder procedure that creates an xml document which is then indexed into a dummy column on the parent table. This works fine. However I need to add an mdata section to the index, via my xml document. I haven't seen any examples of this being done in conjunction with the ctxsys.auto_section_group option of the create index statement, and am wondering if it is possible?
    Could somebody furnish me an example of how I achieve this.
    Oracle 11.2.
    Thanks
    Ralph

    You can't use MDATA with AUTO_SECTION_GROUP. AUTO means it automatically assigns zone sections for every tag it finds - if you want anything other than zone sections you must use BASIC_SECTION_GROUP, XML_SECTION_GROUP or HTML_SECTION_GROUP and manually define your sections.

Maybe you are looking for

  • How to convert a .jsp to a .java/.class file for use in peoplesoft

    Hi java/jsp experts, I want to convert a .jsp to a .java/.class file. is there a tool available, please let me know if you have any pointers.... or can i do it manually: these are a few lines that the .jsp contains, and i would like to translate this

  • Why did the back, forward and refresh buttons stop working

    When I started the computer for first time today I opened firefox I no longer can use the back, forward or refresh buttons when visiting sites. Alaso even though I have selected firefox to open with home page it opens with a bland until I hit home bu

  • GR reversed inspite of invoice

    We have an issue with GR being reversed,inspite of invoice postings. OMBZ settings was not the reason. Apperciate,if someone can Assist.

  • FLASHBACK succeeded but OPEN RESETLOGS would get error

    I have Windows XP with 10g 10.2.0.1.0. Please read the message below and please shed a light. Thanks in advance. SQL> flashback database to restore point before_alter; flashback database to restore point before_alter ERROR at line 1: ORA-38795: warni

  • Variant Config on different document type

    My situation is users are allowed to enter partial config in QT, but have to enter all config in OR. For example, there are 10 characteristics for a material. In QT, users are optional to enter (say 5 out of 10). However, in OR, all 10 Characteristic