Can I put both RMI server and client in a same program

hi everybody...
I wanna know that can I use RMI server and client in a same program....My idea is like that I wanna use the same program for client and server....When I open my program, I can accept connection from other program and if I want to connect to others, I can also connect it. I expect you to understand my question. Here are the sample code for my program...
package Chat.Rmi;
import java.lang.*;
import java.util.*;
import java.rmi.*;
import javax.swing.*;
import java.net.*;
import java.rmi.server.*;
import java.rmi.registry.*;
public class netKitManager implements netKitInterface{
    public netKitManager(){
        try{
        reg = LocateRegistry.createRegistry(4242);
        reg.rebind("NetKitServer",this);
        }catch(RemoteException re){
    public void DirectConnect(String ip){
        try{
        netUser = (netKitInterface) Naming.lookup("rmi://"+ip+":4242/NetKitServer");
        JOptionPane.showMessageDialog(null,"Connection succeded!");
        }catch(NotBoundException nbe){
            JOptionPane.showMessageDialog(null,"There is no server at specified IP address!");
        }catch(MalformedURLException mue){
            JOptionPane.showMessageDialog(null,"IP adress may be wrong!");
        }catch(RemoteException re){
            JOptionPane.showMessageDialog(null,"Remote exception occured!");
    public void SendMessage(String msg){
        try{
        netUser.SetMessage(msg);
        }catch(RemoteException re){
    public void SetMessage(String msg) throws RemoteException{
        chatKit.SetMessage(msg);
    private netKitInterface netUser;
    private Hashtable netUserList;
    private Registry reg;
}

Yes it can be done. I have done it.

Similar Messages

  • CAN I INSTALL BOTH (ORACLE 9IAS AND ORACLE DATABASE )INTO SAME MACHINE.

    oracle 9ias and oracle 9i database in same machine Feb 25, 2003 11:22 PM
    Reply
    Dear Friends,
    I installed oracle 9ias. and then i hosted my form,report into that server . All was working properly.
    at this time my database was into another machine.
    then i installed oracle 9i database into the same machine
    (as the oracle 9ias was installed)
    at the instalation of oracle 9i database one error comes
    and shows that Agent configuration Assistant Installation
    fail.
    but After installation of database it work properly.
    there is no problem.
    but when I try to run from through web(by using oracle 9ias)
    it gives Internal error(500).
    i check and find that my appache server for 9ias is working properly and in services of windows 2000 no error comes.
    HOW CAN I INSTALL BOTH (ORACLE 9IAS AND ORACLE DATABASE )INTO SAME MACHINE.
    With regards
    Siddharth Singh
    [email protected]

    Hi James,
    Have u ever tried ORACLE 9iAS R2 on Redhat Linux ?
    If yes what is the version of RH Linux you were using ?
    Any docs for that ?
    [email protected]
    Regards
    Amudharasu

  • Can I use both iPhoto 6 and 5 on the same Mac?

    I gave up on iPhoto 6 when it comes to publishing web galleries (see my posts at http://discussions.apple.com/thread.jspa?threadID=456532&tstart=0 )
    Can I use both iPhoto 6 and 5 on the same Mac?
    Thanks!

    Lior:
    Welcome to the Apple Discussions. Yes you can but it takes a lot of caution! You can have both application running their own library. But the problem comes in when you launch V5 into the last used library, a V6 library, and it can corrupt that library so it won't open in V6 again. Conversely, if you open V6 and the V5 library was the last to be opened and you don't pay attention, you'll convert it to a V6 and lose the V5 access.
    So you have to make sure you ALWAYS launch iPhoto with the Option key depressed and manually select the library to use each time. Also Name each library differently. I use V6 LIbrary and V5 Library. You can rename your current one and then launch iPhoto with the Option key depressed and navigate to it to open it.

  • UDP server and client running on same machine

    Hi all,
    I can't get the QuoteServer example to work. I am trying to run both server and client on same machine since I only have one machin available at the moment.
    I am using win xp behind a firewall. Anything that might interfere?
    With some System outs I can see that the server is waiting for request but never getting any...

    Restarted computer and now it works. Are ports locked up if I get an exception in the 'wrong' place?

  • RMI server and client in one application - Exceptions during some calls

    I wrote an application, which is an RMI-Server (Server1), and another separate application, which is an RMI-Client (Client1). Because I wont use dynamic class loading, I gave the client beside the interface.java also an interface_implementation.java, which is only a dummy of the original interface_implementation of the server. This dummy contains only declarations of the methods (parameters and return values) and no functional code. From this dummy the _stub.class is generated, and it works fine - no problem.
    Now I want to modify Client1 to become also an RMI-Server (Server2) for a second, separate Client (Client2), the methods used are different from the first RMI connection. This Client2 uses a dummy of the implementation of Server2 in the same way as described above. The application Client1+Server2 only has to "translate" the calls from Client2 to Server2 into calls of Client1 to Server1 (Server1 is not changed at all). In case of primitive method parameters or return values this chain of RMI-applications works fine, but in case of more complex structures (my own classes) during the call of Client1 to Server1 an "ClassNotFoundException: access denied to class loader" occurs by running through the stub. Both stub.classes are found, all of the applications know the objects needed, the call of Client1 to Server1 is exactly the same call as it was during the simple version (only Server1 and Client1).
    Does anybody know, why this exception occurs and how I can overcome this ?
    Axel

    I figured out a solution - it's a problem of policies. In detail: Server1's codebase entry (file:) refers to the class directory of Server1's project. In the simple case of only Client1, which has no codebase entry, it works fine without a file permission on the side of Server1. In the complex case of Client1+Server2, which has to have a codebase entry (file:) refering to the class directory of the Server2's project on a separate machine, for exactly the same method call from Client1 to Server1 a file permission entry on the side of Server1 is needed for Server1's class directory. But WHY ???
    It seems to be a little confusing with the codebase entries, many of the posts are contrary to others and to my personal experiences. Some comments given by Adrian Colley throw a little light upon some aspects. Is there anybody, who can explain the whole topic, when, why, and which part of RMI application deals with codebase entries, also in case of not dynamic code downloading ? May be there is also a reference into the java docs, which I didn't found up to now.
    Thanks in advance
    Axel

  • Can you setup both VPN server and Back to My Mac on Lion Server?

    I have been trying to figure out if this is possible for some time. Can you use both Back to My Mac and VPN server services at once on a OS X Server?
    So far here is what I have found:
    - According to http://support.apple.com/kb/TS1629  Back to My Mac and VPN use the same UDP ports(500,4500)
    - I have been able to get my VPN service working by removing all access for Back to My Mac(in System Preferences->iCloud) as well as removing all "Mobile Me" access on our AirPort Extreme.
    The moment I try to add an account to access the network via Mobile Me(ie Back to My Mac) on the Airport Extreme, I am no longer able to make a VPN connection.
    Checking the Service VPN Logs, no log entry is shown for the failed connection.
    So, my questions are:
    1. Has anyone been able to get these two working on the same server/network?
    2. Is there any way to change the default ports used by the VPN server service on Lion Server?
    Thank you to anyone that can provide any suggestions.

    Just as FYI....I just started using iCloud and tried the "back to my mac" on a mac server that is my VPN server.
    Enabling "back to my Mac" prevents the VPN from being useable.
    Disable "back to my mac" and the VPN works again, as verified from both another MAC and an iPhone.

  • Where can one fine TCP socet server and client example VI's for Labview 6.0

    We've inherited an older system containing two PXI systems and one PC.  The Labview -6.0 programs running on the three systems need to be rewritten from ground zero.
    In hopes of saving a great amount of time, I am looking for a couple of TCP socket VI's that can be used to set up communications between the applications.  There doesn't appear to be a backwards compatibility from examples found in newer versions of Labview.
    Thanks,
    KGTang

    kgtang wrote:
    We've inherited an older system containing two PXI systems and one PC.  The Labview -6.0 programs running on the three systems need to be rewritten from ground zero.
    In hopes of saving a great amount of time, I am looking for a couple of TCP socket VI's that can be used to set up communications between the applications.  There doesn't appear to be a backwards compatibility from examples found in newer versions of Labview. 
    Why backwards compatibility?
    Look in examples/comm/tcpex.llb. Those examples are still mostly unchanged in the newer LabVIEW versions too.
    Rolf Kalbermatter
    Rolf Kalbermatter
    CIT Engineering Netherlands
    a division of Test & Measurement Solutions

  • Layout: can you have both 2 column and 1 column in same doc?

    Can you?

    The tab definition determines whether or not the tab gets leaders. Right
    now you have, probably, one tab defined, and that tab is defined with
    leaders. You need two tabs, first one defined without leaders (to get
    from auto number to head), second one defined with leaders (to get from
    head to page number). I actually like to use another tab in there so the
    leaders all line up and stop before they get to the numbers.
    Kenneth Benson
    Pegasus Type, Inc.
    www.pegtype.com

  • In iMovie HD 6 can you merge both DV widescreen and HD in the same movie?

    I have a Sony HDR-FX1 and have shot both formats and would like to now merge them into the same movie. In my old iMovie it does not appear to allow me to import both formats it will say camera not connected when the camera is set to a different format to what the movie contains.
    Any Suggestions?
    Sam

    For Photos, just drag the photo to the clip where you want it.
    For video, see this article for how to do b-roll.
    http://imovie08.blogspot.com/2007/08/how-to-extract-audio-from-clip.html

  • Setup server and client

    I am new in Oracle, so have some question to ask.
    How to set up server and client Oracle in same pc? Can suggest any document?
    which version of Oracle will be recommend?
    I using VB as a front-end.

    Hi,
    Start reading TFM for your version(click)
    . choose your version
    . read cover to cover the "Concepts book"
    . read the developper books
    Advisable version certainly is the last one: Oracle 10g Release 2.
    Regards,
    Yoann.

  • How can a VI be both server and client?

    Hi, 
    I'm new in LabView and I'm trying to build a server and client VI using TCP/IP that runs in two computers. in my program I need both server and client VIs to communicate with each other which means I need both VIs to be server and client. I've tried using a case structure but it doesnt work. The only thing I achieved is a normal server/client system where the server sends a request and the client responses.But i need the client to send requests too.i have attached my VIs to this post.I would appriciate it if someone could help with this problem. 
    Thanks in advanced. 
    Rambaldi.
    Solved!
    Go to Solution.
    Attachments:
    Server-Client.zip ‏41 KB

    Do you really need a client and server on each PC? If you simply need that two to talk to each other they can once the client connects to the server. In most cases you only need one server.
    What Steve said about the not using the same port only applies to two servers on the same machine. A client must use the port the server is listening to and if the client and the server are on the same machine then they will both use the same port. However, only ONE of them is accepting waiting for connections on that port.
    In the code you posted you actually swapped the names. What you call the client is actually the server code and vise versa. In networking a server is an application that listens to an assigned port, accepts connections on that port and provides whatever services it has implemented. A client is an application that establishs a connection to a server. Once a connection is established the two applications can communicate in both directions. The applications themselves will define how the conversation should progress and whether it is a one way conversation or a two way conversation. You don't specify what you are trying to accomplish but I suspect you only need a single server.
    In TCP, every connection is defined by the source and destination IP addresses and the source and destination ports. The server uses a known port (FTP is port 21, HTTP is 80, telnet is 23, or some custom port in the user space beyonds the reserved ports) to listen for connections. The client will use the well known port of teh server and generally picks a random port for its port number. The LabVIEW VIs do this automatically. This is how a server and a client on the same computer can use the same port number. Two servers however cannot. The server application can spawn a child task allowing it to service multiple connections at one time though. Each connection will be unique though since the client's port number, address or both will change for each connection.
    OK, end of networking 101.
    Can you describe in a bit more detail what exactly you want to accomplish. Given that I could probably provide you with more information for your application.
    Mark Yedinak
    "Does anyone know where the love of God goes when the waves turn the minutes to hours?"
    Wreck of the Edmund Fitzgerald - Gordon Lightfoot

  • JAX-RPC: Web service where both server /and/ client are services?

    I'm considering a two-way Web service in an application that I'm designing and would appreciate any insight from prior experience.
    This will be a standard client-server application, where the server broadcasts messages and the client, in turn, can request further information about the messages that it receives (think RSS-style updates, but with more interaction). [strong]However[strong], instead of having the client poll the server for new messages, I'd like to have the client register itself with the server as a message listener. The server is currently implemented as a Web service on port X. I'd like the client to register itself with the server, and then receive messages on port Y.
    I'm considering a design like the following (note the directions of the inheritance arrows):
    ( Server class )  --<-- ( RemoteServerImpl class ) -->-- / RemoteServer interface /
           |
    ( Listener class ) --<-- ( RemoteListenerImpl class ) -->-- / RemoteListener interface /Some considerations:
    * In both cases, the client and server are broken out into an interface and two classes. The non-Remote classes implement all of the functionality. The RemoteX interfaces declare the methods that will be exposed via RPC, and the RemoteXImpl classes are empty subclasses of the non-Remote classes.
    * In order to register itself with the Server, the Listener must be passed in as a method parameter, and thus conform to the JAX-RPC specification for value types. However, value types can't implement java.rmi.Remote.
    * Only the Server and Listener know anything about each other.
    * This application can be run either remotely or locally, depending on how the Server and Listener are instantiated. For the latter, they're instantiated directly and the listener is registered with the Server. For the latter, the RemoteX interfaces will point to the service stubs.
    * I don't see an easy way to allow both the Server and the Listener to have references to each other (at least now without some casting magic), since one of them will have to conform to the value type specification, which requires that all of its fields must be valid JAX-RPC types.
    I've got the Server portions implemented and working, and am now going to turn to the Listener stuff. Can anybody see a fundamental problem with this design, or can suggest something better?

    Hi There,
    Because web services are fundamentally a Services-oriented architecture, and not an Object-oriented one, you are unable to pass objects by reference (only by value) hence the design decision to not allow rmi.Remote objects to be sent across the wire. The best way would be to abstract an object which does itself not represent a server, but a route to a server (lets call it ServerPointer). This must contain address, port, service info, etc.
    Now, in your Server class, create a factory method which takes a ServerPointer, and returns a reference to a
    remote server, e.g. protected Server createServer( ServerPointer p ) (using the necessary APIs to get such a reference)
    Hope this helps...

  • Try to use one comupter as both server and client

    Hello, everyone, I am just trying to use my own computer as both server and client to test some codes about networking. For example, use the sample code in java tutorial which is used to test Echo server(code is listed below). Is there anything I have to do to set my computer, such as set my hostname or something like that?
    I am a pure newbie. And the purpose of this question is to test some code including socket on one PC without connect to internet.
    I have tried to change the name "taranis" in the following code to the computer name of my own PC, but it doesn't work, and said: Couldn't get I/O for the connection to: (my computer name).
    import java.io.*;
    import java.net.*;
    public class EchoClient {
    public static void main(String[] args) throws IOException {
    Socket echoSocket = null;
    PrintWriter out = null;
    BufferedReader in = null;
    try {
    echoSocket = new Socket("taranis", 7);
    out = new PrintWriter(echoSocket.getOutputStream(), true);
    in = new BufferedReader(new InputStreamReader(
    echoSocket.getInputStream()));
    } catch (UnknownHostException e) {
    System.err.println("Don't know about host: taranis.");
    System.exit(1);
    } catch (IOException e) {
    System.err.println("Couldn't get I/O for "
    + "the connection to: taranis.");
    System.exit(1);
         BufferedReader stdIn = new BufferedReader(
    new InputStreamReader(System.in));
         String userInput;
         while ((userInput = stdIn.readLine()) != null) {
         out.println(userInput);
         System.out.println("echo: " + in.readLine());
         out.close();
         in.close();
         stdIn.close();
         echoSocket.close();

    Did you write the EchoServer and start it on your
    machine, listening on port 7?
    You can have the client and server running on the same
    machine or different machines, but they have to be
    separate pieces of software.
    Write a separate EchoServer class that starts up and
    listens on that port. Then start the EchoClient and
    make the connection.
    %yeah, I didn't wrote the EchoServer class. But I thought it is automaticly included and therefore has run once I start my computer.
    If I write a EchoServer class, then how should I set the host name of the EchoClient, just simply change "taranis" to my computer name (change "echoSocket = new Socket("taranis", 7);" to echoSocket = new Socket("(my comptuer name)", 7);"?

  • RMI Server and RMI Client Problem

    First, Hi!
    I have create my RMI Server and a RMI Servlet client.
    I can run the server and servlet first time and it works fine.
    Then, I stop rmiregistry and server.
    Then, I start rmiregistry and server for a second time but my RMI Servlet client gets a
    java.rmi.ConnectException: Connection refused to host: xxx.xxx.xxx.xxx; nested exception is: java.net.ConnectException: Connection refused
    If I copy the class again where the servlets resides, it works again. But I have to keep doing that. I have to keep copying the class file to the servlet directory every 2nd time I try to run it for it to work.
    Anyone know what am I doing wrong?

    First, Hi!
    I have create my RMI Server and a RMI Servlet client.
    I can run the server and servlet first time and it
    works fine.
    Then, I stop rmiregistry and server.
    Then, I start rmiregistry and server for a second time
    but my RMI Servlet client gets a
    java.rmi.ConnectException: Connection refused to host:
    xxx.xxx.xxx.xxx; nested exception is:
    java.net.ConnectException: Connection refused
    If I copy the class again where the servlets resides,which class file ? u mean RMIServer's class files ??
    I have faced the same problem too. In my case if i just restart my Tomcat webserver the error goes and the servlet is very well able to connect back to the RMI Server
    it works again. But I have to keep doing that. I have
    to keep copying the class file to the servlet
    directory every 2nd time I try to run it for it to
    work.
    Anyone know what am I doing wrong?

  • Comprised of both server and client components

    Hello all
    We all consult an open source project and download freely the source code and the documentation for the server as a tarball. The well known open source project is Paragent which its platform is comprised of both server and client components written in Lisp, C++ and Java. just take a look and drop your suggestions.
    Thanks for any help,
    Bmora96

    Huh?

Maybe you are looking for

  • Help needed with conditions in Table View

    Another question regarding the dashboard we are building: We use a custom function module to display marketing attributes for a particular customer. There are three kinds of marketing attributes of which we want to display the value: - Z_QUADRANT - Z

  • Error While saving the Production Order

    Dear Experts Pls let me know why am getting the below error while saving the production order after release.. PSFC_STD_LAYOUT does not exist Message no. SSFCOMPOSER004

  • ALV Report  clarrification

    Hi All, I have an ALV report in which i am using reuse_alv_list_display and this executes with certain details like Delivery no ,  sales organisation , reference no, transport group, shipping point and so on .  the report gets displayed as below show

  • Missing output format radio button in SAP Query

    Hi SAP Gurus We have SAP Query which as created in 4,6c. After the upgrade to ECC 6.0 We found that the output format radio button is mising in SAP Query. We are unable to choose teh output format. How can we have the radio button back? Appreciate yr

  • Illustrator CC doesn't work anymore

    Illustrator CC was working perfectly. Since last week it will no longer open and crashes before the splash screen opens. I re-installed it but it still don't work. I saw in other discussions that i'm not the only one.