Results 1 to 3 of 3

Thread: nio issue

  1. #1
    Join Date
    Mar 2010
    Posts
    2
    Rep Power
    0

    Default nio issue

    Hi,

    I have 2 server sockets accepting connections on ports X and Y. Both registered on selector.

    One connection on first server socket has to be mapped to another connection on other server socket.

    Messages on connection on first server socket must be passed over to connection on second server socket and vice versa.

    How do we handle the mapping part.

    Regards
    DM

  2. #2
    mrmatt1111's Avatar
    mrmatt1111 is offline Senior Member
    Join Date
    Aug 2009
    Location
    San Jose, CA, USA
    Posts
    320
    Rep Power
    5

    Default

    You are saying that the client is making two connections with the server, correct?

    Have the client pass over some form of ID, like a username, which you can use to pair the two connections. If you don't want them to use a username then instead when they connect pass an ID to them (an integer for example) which they pass back to you when they make the second connection.

    You can store the two connection in two serperate hashmaps with the id as the key, or in a holding class that stores the two connection and keep that in a single hashmap or list, or you can do it some other way.
    My Hobby Project: LegacyClone

  3. #3
    Join Date
    Mar 2010
    Posts
    2
    Rep Power
    0

    Default

    Hi,
    You mean to say that the other client must send its first message with some unique identfier in the packet?

    Let me know if I am wrong in understanding.

    Assuming that my understanding in correct, i would require to parse each message in isReadable() to see if the unique identifier is present in it or not.

    Is there any other way which can be thought of?

    Regards
    Deepak

Similar Threads

  1. JSF issue
    By premjo in forum New To Java
    Replies: 0
    Last Post: 02-14-2010, 02:19 PM
  2. Issue
    By FlashNinja in forum New To Java
    Replies: 20
    Last Post: 11-28-2009, 09:44 PM
  3. PDF Box issue
    By jazz2k8 in forum Advanced Java
    Replies: 0
    Last Post: 03-20-2009, 11:04 AM
  4. Issue jsp with FireFox
    By dimuthunsj in forum JavaServer Pages (JSP) and JSTL
    Replies: 1
    Last Post: 10-10-2008, 11:08 AM
  5. Issue
    By chaitu444 in forum New To Java
    Replies: 2
    Last Post: 11-06-2007, 07:49 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •