iOS Question Array of sockets?

Discussion in 'iOS Questions' started by techknight, Apr 5, 2015.

  1. techknight

    techknight Well-Known Member Licensed User

    Can we create an array of sockets?

    Basically I want to have multiple simultanious connections to different IP addys. (say max of 5, all internal IPs) at any point, and want them all to go through the same ONE asyncstreams handlers and events, with the same ONE socket successful event. not 5 individual events.

    any ideas? Thanks.

    Basically to connect to my embedded devices.
     
  2. Erel

    Erel Administrator Staff Member Licensed User

  3. techknight

    techknight Well-Known Member Licensed User

    I took a look at it, but I am not really following it? That B4J app is acting as a server.

    I am doing the opposite. I am connecting to multiple server/service IP addresses.

    Basically, I want my tablet to connect to a sensor net. There are maybe 4 or 5 sensors at different internal IP addresses, all the same port. I am Sending/receiving serial data to each one simultaneously.
     
  4. Erel

    Erel Administrator Staff Member Licensed User

    It doesn't really matter if it is a server or client. Once there is a connection you work with AsyncStreams object. You can see in this example how the server manages the multiple AsyncStreams object.
     
  5. techknight

    techknight Well-Known Member Licensed User

    Well, with android I always did Socket1 as socket. Then it raises Socket1_Connected, which its at this point where I need to open the astreams handler. But for multiple IPs, i would need to declare Socket2, Socket3, etc... No? that means i would need an event handler for each and every socket?

    I was hoping there was something like Dim Sockets() as Socket and it would raise say a Sockets_Connected(index as integer). That would be nice.

    like I said there are some things I just dont quite understand.
     
  6. Erel

    Erel Administrator Staff Member Licensed User

    Go over the B4J example. It is only 90 lines and it is exactly what you are trying to implement.
     
Loading...
  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