Java Sockets help

Discussion in 'OT Technology' started by tailgate, Oct 22, 2003.

  1. tailgate

    tailgate Whats with today, today?

    Joined:
    May 4, 2001
    Messages:
    274
    Likes Received:
    0
    Location:
    Texas
    I need to do this:
    There are reliable socket connections (TCP) between every pair of nodes, and all messages are exchanged over these connections. All connections are established in the beginning and stay intact until the program ends.

    It needs to be multi-threaded, so this is what I am doing:
    let the number of nodes be 8 (can be up to 64)

    I start up 8 "servers" on different ports that when accepting a client start a thread to handle it.

    then I start 8 clients that connect to each of the servers. this works, but when going up to 64 node, that is 64 server starting 64 threads each, 4096 processes (or threads), the only problem is Im limited to like 1024 processes I can run on the unix box.

    Is this the wrong way to implement this? its for an Advaced OS project

    thanks for the help
     
  2. crotchfruit

    crotchfruit Guest

    you could adopt some sort of multi-threaded/polling hybrid. that is, say, 64 threads each polling 64 sockets.

    polling on a socket is pretty simple, from what i remember. you basically attach a bufferedreader to the input stream and use the ready() method to determine if data is ready for extracting. new data won't show up as ready until newlines are sent (so you can divide info into discreet chunks with the newline character... and take it out with a readline)
     
  3. tailgate

    tailgate Whats with today, today?

    Joined:
    May 4, 2001
    Messages:
    274
    Likes Received:
    0
    Location:
    Texas
    Ill have to look into that. thanks
     

Share This Page