Advertisement
Help Keep Boards Alive. Support us by going ad free today. See here: https://subscriptions.boards.ie/.
If we do not hit our goal we will be forced to close the site.

Current status: https://keepboardsalive.com/

Annual subs are best for most impact. If you are still undecided on going Ad Free - you can also donate using the Paypal Donate option. All contribution helps. Thank you.
https://www.boards.ie/group/1878-subscribers-forum

Private Group for paid up members of Boards.ie. Join the club.

Java network programming

  • 28-04-2005 01:07PM
    #1
    Registered Users, Registered Users 2 Posts: 648 ✭✭✭


    I want to connect two computers over a network using java and have a continous communication. Just like an instant text conversation. At the console window. I was wondering how to do this. Is the best way to use ServerSocket Channels. For instance something like:

    ServerSocketChannel serverChannel = ServerSocketChannel.open();

    ServerSocket ss = serverChannel.socket();
    ss.bind(new InetSocketAddress(1024));

    I want the console window to remain open while text is sent back and forth.


Comments

  • Closed Accounts Posts: 25 dan_pretty_boy


    Hi,

    Have a look at Jabber...


    danny


  • Registered Users, Registered Users 2 Posts: 648 ✭✭✭Neo#


    I actually want to do this myself manually as its part of a project. Thanks anyway.


  • Registered Users, Registered Users 2 Posts: 304 ✭✭PhantomBeaker


    I'm just guessing here but maybe try this?

    put it in a loop like
    while(serverChannel.isOpen()){
    // body of text is here?
    }
    

    So once the connection closes the console window can close. That's just my first impression. I could be wrong here.


  • Closed Accounts Posts: 3 I


    Depends what kind of connection you want. If you need one machine to be able to execute code on the other then take a look at RMI


  • Registered Users, Registered Users 2 Posts: 648 ✭✭✭Neo#


    Will do. Thanks.


  • Advertisement
Advertisement