Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie
Hi there,
There is an issue with role permissions that is being worked on at the moment.
If you are having trouble with access or permissions on regional forums please post here to get access: https://www.boards.ie/discussion/2058365403/you-do-not-have-permission-for-that#latest

A networks in java question

  • 17-03-2004 3:47pm
    #1
    Registered Users, Registered Users 2 Posts: 659 ✭✭✭


    I have two computers connected via a lan connection. On each computer i have a javaswing GUI. The problem is as follows.......


    On computer 'A's GUI I enter a string into a textfield and press the submit.

    What I want to do is...

    Take the string from the textfield on computer 'A' and display it in a textfield in the GUI on computer 'B'.

    Am i right in saying the code would look something like this??....

    public static String message;
    message = TextfieldA.getText();
    // how do i then send it to the textfield on computers B's GUI???????

    is it?...

    TextFieldB.setText(what goes in here?);


Comments

  • Registered Users, Registered Users 2 Posts: 678 ✭✭✭briano


    Are the two computers "talking" to each other over the network connection? That would be the first step. After that, the method of displaying the message in B's Textfield depends on how you chose to send messages across to that computer.


  • Registered Users, Registered Users 2 Posts: 3,958 ✭✭✭Chad ghostal


    just like he said youll to use some networking,
    like rmi or sockets or something..
    rmi would probably be the easiest thing to use..
    there are loads of tutorials on the web for this kind of thing..


  • Registered Users, Registered Users 2 Posts: 659 ✭✭✭Chunks


    yeah, they are constantly "talking" to each other over the connection. The problem is I dont know how to send info across the connection and how to retrieve it on the other end. Im not any good with networks. Lehmans terms is the only thing i understand when it comes to this kind of thing. Any more help? Like if you were to write code to do it what would it look like?

    Cheers


  • Registered Users, Registered Users 2 Posts: 678 ✭✭✭briano


    Sorry, I should have been more clear about the computers talking to each other. What I meant to say was "are the two java applications communicating with each other?" I'll take it that they are not.

    If you are handy with interfaces and don't mind some messing around then use java RMI. The tutorial is here . Read through it and it should make it clear enough.

    If you just want to send text, in a fairly predictable manner (say, always from program A to program B), between the two applications then you could use Sockets. The tutorial for sockets is here


  • Registered Users, Registered Users 2 Posts: 1,350 ✭✭✭skywalker_208


    Sockets is definately the way to go for something this simple.... If u have access to a library get the Dietal & Dietal Java How To Program third or fourth edition.... that has a pretty good chapter on this kind of stuff....


  • Advertisement
  • Registered Users, Registered Users 2 Posts: 659 ✭✭✭Chunks


    Ah nice one guys, I really appreciate the help.

    Thanks a lot, very helpful


  • Registered Users, Registered Users 2 Posts: 68,317 ✭✭✭✭seamus


    Sounds like you are doing a chat program.

    Afaik, there are 3 main ways to run chat services:
    Direct Client Connection: You have one program. It incorporates a GUI, a client socket set, and a server socket set. Basically, given an IP address of another machine, it connects to the other client and start chatting. This is the basis of things like winchat.

    Server Relay: You have two programs, One is a (usually) GUI-less server, the other a client with no server, just a GUI on top of client sockets. The clients connect to the server, which then relays any messages to any clients who are listening. This is the basis of IRC.

    Server negotiated Direct Client Connection (May not be the correct name for it): An amalgamation of the two. Clients connect to the server. When a client wishes to connect to another one, it gets the relevant information from the server (ip address, ports, some authentication info where necessary), and then initiates a DCC. Afaik, this could be the basis on which things like MSN Messenger work, but I could be very wrong.

    This page might be of use to you: http://www.javaworld.com/javaworld/jw-01-1997/jw-01-chat.html

    There could be pages of threads discussing the relative benefits/shortcomings of each, as well as ways to do it, but which way you do it depends on how much effort you want to put in, and of course your requirements (assuming it's for college).

    If it's not a chat program you're doing, I've just wasted 15 minutes of my life :D


  • Registered Users, Registered Users 2 Posts: 491 ✭✭Silent Bob


    Originally posted by seamus
    Sounds like you are doing a chat program.
    I could imagine Clippy showing up in Visual Studio to say this :)


Advertisement