B4J Question Sockets and threading

Discussion in 'B4J Questions' started by wl, Mar 29, 2015.

  1. wl

    wl Well-Known Member Licensed User


    As I understood in the past sockets are not working in a Multi-threaded way. All calls are serialized.
    Is there any way in running them in different threads ? The webserver (which is multithreaded) is not really an option for me.

    Thanks !
  2. Erel

    Erel Administrator Staff Member Licensed User

    If you are using AsyncStreams then the communication is indeed multithreaded.
  3. wl

    wl Well-Known Member Licensed User

    Hi Erel,

    Thanks but I am a bit lost. If using Sockets with Asyncstreams then I guess internally the communication is multithreaded, but the events are serialized, is that it ?

    I was just wondering how stable/performant it is to write a Socket server application in B4J when multiple connections are being made.

    lemonisdead likes this.
  4. Erel

    Erel Administrator Staff Member Licensed User

    That is correct. The events are executed on the main thread.

    It is very stable and the performance should be good assuming that you are not blocking the main thread for too long.

    The question is how many concurrent connections do you want to handle? A real server should be implemented with jServer library.
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice