Conflict between socket and RMI

Hi
I wrote a program in client-server using socket and it was fine. I also wrote a client-server program using RMI. Fine as well. But after I connected the client-server using socket (open socket, send-receive messages, close socket), then use RMI. I got java.rmi.NotBoundException.
Would anyone have a look and provide your feedback please? Thanks.
big J
*****************this is Server.java ***************************
package single;
import java.io.*;
import java.rmi.Naming;
import java.rmi.RemoteException;
import java.net.*;
import java.rmi.*;
public class Server
extends Thread {
public static final int SOCKETPORT = 5555;
private String serverName;
public Server() throws IOException {
System.out.println("*** socket opened ***");
serverName = new String("localhost");
ServerSocket serverSocket = new ServerSocket(SOCKETPORT);
Socket socket = serverSocket.accept();
InputStream is = socket.getInputStream();
BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(is));
System.out.println(bufferedReader.readLine());
OutputStream os = socket.getOutputStream();
PrintWriter printWriter = new PrintWriter(new OutputStreamWriter(os), true);
printWriter.println("from server");
os.close();
is.close();
socket.close();
System.out.println("*** socket closed ***");
public void runServer() {
System.out.println("*** start of run():RMI ***");
System.setSecurityManager(new SecurityManager());
try {
RMIInterfaceImpl rMIInterfaceImpl = new RMIInterfaceImpl();
Naming.bind("//" + serverName + ":9999/RMIInterface", rMIInterfaceImpl);
catch (RemoteException ex) {
catch (MalformedURLException ex) {
catch (AlreadyBoundException ex) {
System.out.println("*** end of run():RMI ***");
public static void main(String args[]) throws Exception {
Server server = new Server();
server.runServer();
******************this is Client.java **************************
package single;
import java.io.*;
import java.net.*;
import java.rmi.Naming;
public class Client {
private String serverName;
private final static int SOCKETPORT = 5555;
public Client() throws IOException {
serverName = new String("localhost");
Socket socket = new Socket(serverName, SOCKETPORT);
OutputStream os = socket.getOutputStream();
PrintWriter printWriter=new PrintWriter(os, true);
printWriter.println("from client");
InputStream is = socket.getInputStream();
BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(is));
System.out.println(bufferedReader.readLine());
is.close();
os.close();
socket.close();
public void runClient() throws Exception {
System.out.println("*** start of runClient():RMI ***");
System.setSecurityManager(new SecurityManager());
RMIInterface rMIInterfaceImpl = (RMIInterface) Naming.lookup(
"//" + serverName + ":9999/RMIInterface");
String str = rMIInterfaceImpl.print();
System.out.println(str);
rMIInterfaceImpl.serverSide();
System.out.println("*** end of runClient():RMI ***");
public static void main(String args[]) throws Exception {
Client client = new Client();
client.runClient();
***************** this is RMIInterface.java ***********************
package single;
import java.rmi.Remote;
import java.rmi.RemoteException;
interface RMIInterface
extends Remote {
String print() throws RemoteException;
void serverSide() throws RemoteException;
********************* this is RMIInterfaceImpl.java ***************
package single;
import java.rmi.RemoteException;
import java.rmi.server.UnicastRemoteObject;
public class RMIInterfaceImpl
extends UnicastRemoteObject
implements RMIInterface {
public RMIInterfaceImpl() throws RemoteException {}
public String print() {
return new String("hello world");
public void serverSide(){
System.out.println("this should appear in serverside");

I think you have a timing problem between your client and server. As soon as your client and server programs have finished their socket communication, they will both do their "runServer"/"runClient" methods. If the client attempts to lookup the server before the server has registered itself via Naming.bind(), I would expect that's why you're getting a NotBoundException in the client.
You probably wouldn't use the design of your test client/server for something significant, but a quick and dirty way to make this work might be to have the client call Thread.sleep() for a few seconds before trying to do the lookup.

Similar Messages

  • Making choice between socket and RMI

    I never use RMI, but i am familiar to socket programming. i want to write an online game, I know that use RMI will easy than use socket, could anyone tell me what factors will affect the choice between using socket and RMI if don't consider which one i am familiar ?
    thanks
    jacky

    I would consider the amount of traffic your online game is going to be generating. Obviously, if the traffic is the bottleneck, you will want to optimize it as much as possible.
    I can see that if you are familiar with sockets and socket programming, where this is very appealing because after all, you can't get much faster than raw sockets. Also, the Java APIs around sockets are much easier than the equivalent BSD Socket C/C++ libraries.
    Still, RMI has much more to offer.
    o It is relatively easy to set up a connection
    o exceptions will be thrown when problems occur
    o serializing classes is so easy it's laughable
    o If performance becomes an issue, you can (as the previous poster suggests) create your own custom socket factory which optimizes the used bandwidth. Options here include compression if you have the CPU cycles to spare.
    o There are mechanisms in place for working RMI over firewalls
    Many of the things that RMI offers, you might find yourself re-writing in your own socket-based API. Personally, I would choose RMI.

  • Difference Between JMS and RMI

    Difference Between JMS and RMI in J2EE Technologies

    STFW
    JMS - http://www.google.co.za/search?hl=en&q=what+is+jms&meta=
    RMI - http://www.google.co.za/search?hl=en&q=what+is+rmi&meta=

  • Error while trying to synchronize audio and MIDI.  Sample rate 42804 recognized.  Check conflict between Garageband and external device.

    Sometimes, while playing back my software instrument songs, I get an intermittent pop-up error message, saying "Error while trying to synchronize audio and MIDI.  Sample rate 42804 recognized.  Check conflict between Garageband and external device."
    (Sometimes the five digit number is different, but remains a five-digit number beginning with "4".)
    Simultaneously, the song stops until I press the "Okay" button in the pop-up window.
    When I continue to play the song, the sound is jerky and clipped, and the playhead doesn't keep up with the song, and then suddenly jumps to the part of the song currently being played.
    There's also a sound of static.
    The issue seems to occur whether or not I have my MIDI controller turned on and plugged into my desktop Imac.
    Tony

    Hello,
    open your Audio MIDI Setup utility and set the input to 44100
    https://discussions.apple.com/message/12710638#12710638

  • How can I resolve conflict between itunes and Windows 8.1

    When downloading itunes to my laptop computer, using Windows 8.1 my email/network account will not work on that computer.  It is fine on other devices such as ipad and Windows phone.  I can also pick up emails on online on the same laptop.  There appears to be a conflict between itunes and Windows 8.1

    Please see  Boot Camp for comments.

  • [JS CS3] Conflict between palettes and panels

    Hello,
    I am having a conflict between panels and palettes. Hopefully I can get some direction without having to copy the code here, because it is very long.
    I have a window of the palette type. This palette has buttons and radio buttons. The buttons call up various functions.
    The radio buttons, however, make visible/invisible a series of panels in the palette. The panels are stacked upon each other, only one of which is visible at any one time, depending upon which radio button is selected.
    One of the buttons in the palette calls up another palette (which also has a series of buttons for various functions). Let's call it the little palette. The problem is, that after the little palette is called up, the radio buttons in the big palette no longer work. I can select them but they will not make visible/invisible any of the stacked panels. The buttons in the visible panel work as well as all the other buttons that are always visible. The only thing that does not work are the radio buttons.
    My only workaround is to just dismiss the palette and call it up again. But I'd rather fix this bug.
    Any ideas? If I need to I can strip down the coding leaving only the essentials, but rather not take the time if this is a problem others have run into and hopefully have a solution for.
    Thanks,
    Tom

    Thanks.  I'll give it a try, but I even uninstalled both programs, tried
    reinstalling Reader only, and when that didn't work, uninstalled Reader and
    then reinstalled Acrobat.  Still a problem.  The particular website is
    www.officeally.com, and it opens the PDF file in a browser window, I believe
    using an ASP file.
    Larry

  • Differnce between RPC and RMI

    Hello,
    Can anyone please tell me in detail the difference between RPC and RMI? If possible can you pls give examples?
    Thanks in advance.
    KiranJyot

    Thank you for the reply.
    Yes, I did google about this. But, it was not clear to me. I did ATM application using both RPC and RMI. Even though, it worked fine and did not lose points in my assignments, unfortunately the concepts were not clear.
    Can you please explain me what does it meant by - there is objects involved in RMI. In RPC, invoking functions is done through a proxy function. It will be great if you can explain it using ATM application.
    Regards,
    KiranJyothi

  • Name space conflict between static and instance method

    Hello,
    there seems to be a very unfortunate name space conflict between static and instance method name. Consider:
    static String description() that should return a description of a class.
    String description() that should return a description of an instance.
    That seems to confuse the compiler. How come? Static and instance methods don't have anything to get confused about.
    Thanks for any insights :-)

    Umm...jeez.
    It's not a bug, it's the way it's supposed to be.
    Since a static method can be called the same way an instance method
    A instance = new A();
    A.staticMethod();
    instance.staticMethod();it's not allowed.
    Also in the class, you can call
    public void myMethod() {
          instanceMethodInClass();        // You don't need this, it's superfluous
          staticMethodInClass();          // You don't need the class name.
    }If you didn't understand, then just accept the fact that it is so. Some day you'll understand it.

  • Software conflict between iPhoto and Sony MP3 player

    I am experiencing a major software conflict between iPhoto and my Sony MP3 player (model: NWZ-E443). In the past, whenever I connect the MP3 to my 2009 MacBook Pro, iPhoto always opened. I would simply close iPhoto and everything would be OK, though. But after upgrading iPhoto a few months ago via an upgrade download I am now unable to view images full-screen. Although thumbnails display OK, when I double-click on any of them to display full-screen, the MP3's 'Do Not Disconnect' image displays full-screen instead, even when the MP3 is not connected.
    I have tried reinstalling iPhoto from the original iLife disc, but this didn't work and my fear is that the Sony software has somehow corrupted every image single file in my library.

    Turns out my Mac put code on the mp3 player because after I reset the mp3 player to its 'factory settings', (erasing everything) it went back to normal and now shows up in the finder window.

  • Conflict between VPN and Airport disk

    Hello Folks, I just bought a brand new airport extreme 802n.
    I thought it would be working fine with my Macbook pro, but it doesn't.
    I can't access any externe hard disk or USB Stick through the airport extreme, although the format is FAT32. I checked and checked but found nothing useful. All the settings are default.
    Worth to mention, I always use a cisco VPN client to get connected to the Internet (university student).
    There are few times when I disconnected the VPN Client, the USB Client can be found and read, but not be written.
    I though it is a conflict between VPN and Airport disk. So I tried without VPN, but the USB stick and the extern hard disk still didn't work properly. I have no idea what is happening could somebody help?
    By the way is it possible to set Airport extreme as a VPN router so I don't have to use the cisco VPN client anyway?
    Any reply is appreciated
    Thank you !

    I have an Airport Extreme connected to a cable modem
    with comcast as my isp. The Extreme is connected to
    a G4 dual processor mac via ethernet. I also have 3
    airport expresses around the house to work as range
    extenders. When I had the G4 connect to the Extreme
    via its internal airport card, I had no difficulty
    connecting to any of the Expresses around the house
    with my g4 powerbook. Now that I have the G4 Dual
    directly connected by ethernet to get the fastest
    speed, I cannot get my expresses or my laptop to
    connect through my laptop to the base station. all
    lights are green on the expresses, but running
    network diagnostics on the powerbook shows red or
    yellow for the last two buttons on the right. Do I
    have a configuration problem or an Extreme that won't
    bridge properly?
    Check that the G4 Dual has a location configured with
    only "Built-In Ethernet" activated, and that its
    Ethernet connection isn't shared on AirPort.
    Turn off all your AX and check that your
    PB G4 is able to connect to "your" AirPort network.
    Take advantage of this silence of all your AX
    to run an analysis of your wireless environnement:
    - check that you don't have any neighbor wireless
    network,
    - check that on each of your AX settlement you have a
    very good reception of "your" AirPort network.
    If everything works fine to that point, add one AX to
    your network, and check the reachability of your network
    where you wanted to extend it.
    dan    

  • Difference between socket and http in opera mini

    Sir,
                     can any one say in simple language, what is the difference between socket and http connection. Is http connection possible in opera mini? Which is best suited for economy in use and fee
    Solved!
    Go to Solution.

    First thing to do is to make your phone open the web pages. I don't think the phone has low speeds.
    First
    ask your customer care for correct access point.
    1.
    Copy the access point name you received from custome care to-
    Settings-Connectivity-Packet data-Packet data setting,
    edit active access point.
    Give any name to active access point and activate it.
    Now goto settings- configurations - personal config.- add new- web, give any name to web and press back twice.
    Now again add new access point in personal configurations, give any account name to this access point.
    Copy the access point name which you got from ccare to bearer settings- packet data access pt.
    Press back three times and activate this access point.
    Now in default config. Settings activate personal config.
    Now all apps which need internet connection like
    opera mini should work fine.
    2.
    Saved pages of Opera mini 4.x won't open with opera mini 7.x version.
    Saved pages are stored with an extension .obml.
    Connect memory card to your pc using a card reader,
    you can find them by enabling hidden folders and searching .obml.
    Now right click on any obml file of search results and click open file location or move them to any folder you like and
    note down the files location.
    Now goto saved pages of your opera mini, manage, set folder. Set the folder location to where .obml files are stored
    Now your old saved pages can be opened.
    Hope this helps.
    -------------------If this post helped you, click on accept as solution.------------------
    -----------------------------Appreciate by clicking on white star.----------------------------

  • Conflict between audigy and Olympus voice recor

    I have an audigy se recently installed. Seemed to be working fine until I opened my Olympus voice recorder program. Just opening the program knocked out the sound card and I could not get it back again. No speakers in any application on the computer except the diagnostic test. Then the speakers would play. But no cd's, no wav files, no nothing. Tried checking and unchecking all the boxes. There really aren't that many. Only way to solve the problem was to uninstall and reinstall audigy and not go to Olympus anymore. I've done that several times to confirm that is the problem.
    Any suggestions?
    (5. sourround)

    Bazbear wrote:
    Could anyone help me to resolve the conflict between my Soundblaster Audigy 2ZS and Norton antivirus. The auto protect feature is constantly being turned off on boot up. According to Symantec the problem is caused by conflict between the two soft wares. The Creative page does not mention this at all and the work around on the Symantec site either does not work or entails time wasting closing of programs and re-boots. It is really getting to me now and I wonder if any one knows of a permanent fix?
    Bazbear
    Some past post here mention of this too.....and the mods suggestion does indeed helped some of them resolve it. Perhaps you can try it. What you need to do is uninstall all Norton and Creative software. When you're done with that, install Creative software first follow by Norton stuff.

  • Metadata Conflicts between LR4 and CS6

    I recently upgraded to LR4 and CS6 Extended.  I will offer start in LR4 but switch to CS6 for additional editing.  On some of my thumbnails, I will see a "!" in the upper right hand corner on the thumbnails.  When I click on the icon, a pop-up window appear stating a Metadata conflict has occurred.  The pop-up window gives you two options: Copy file data into the catalog or have the catalog overwrite the file data.  What is the best thing to do knowing you are only working between LR4 and CS6? 

    This is a known issue with the latest PS update. Refer to the pertinent thread on the PS forum.
    Mylenium

  • Is there a conflict between Firefox and Carbomite?

    I have been having problems with unresponsive script errors in Firefox, in both normal and Safe modes. I got the idea that one of my background programs could be causing the problem, so I disabled all of them and then enabled them individually. Enabling Zone Alarm did not cause a problem, so I enabled Carbonite. Sure enough, the unresponsive scripts returned, in both normal and Safe modes. Is there a known issue between Firefox and Carbonite that causes unresponsive scripts and, if so, what can I do about it short of disabling Carbonite? Thanks for any help!

    I have been having problems with unresponsive script errors in Firefox, in both normal and Safe modes. I got the idea that one of my background programs could be causing the problem, so I disabled all of them and then enabled them individually. Enabling Zone Alarm did not cause a problem, so I enabled Carbonite. Sure enough, the unresponsive scripts returned, in both normal and Safe modes. Is there a known issue between Firefox and Carbonite that causes unresponsive scripts and, if so, what can I do about it short of disabling Carbonite? Thanks for any help!

  • Proc*C compilation: conflict between Oracle and TT environments

    We are evaluating the option to add TimesTen to an existing application which is currently using oracle, looking to cache a few tables in TimesTen (AWT Global Cache group) for the purpose of increased performance. The vast majority of our source code related to oracle queries is in embedded SQL in C and C++. I am now looking into what this means for our system builds. We have a few conditions as follows:
    + The use of TimesTen needs to be optional. (e.g. we cannot force customers who are using our product to deploy TimesTen). 
    + We need to use single source (using conditional compilation etc. as needed), to support an Oracle-only as well as Oracle+Times Ten environments.
    I am changing our system-build to incorporate Times-ten PROC*SQL processing for the source code related to the cached tables. I discovered that both the Oracle and TimesTen Pro*C compiler has the same name (proc), for this reason I have provided a directory location for each compiler in the make-file (since I can no longer rely on just $PATH variable to find the right proc utility)
    ## Specify PROC either for Oracle or for TimesTen
    PROC_TT     = $(TT_PROC_BIN)/proc
    PROC_ORA  = $(ORACLE_PROC_BIN)/proc
    My planned strategy for incorporating the build of embedded SQL sources related to tables cached can be summarized as follows:
    1. Make a temporary copy of the source files – adding suffix _ora or _tt to file name to indicate the target database. Also add “tt” to extension of TimesTen files.
    example (file file1.ec is a file with embedded sql in C)
    cp file1.ec file1_ora.ec     
    cp file1.ec file1_tt.ectt
    2. Rules for compiling embedded SQL source into objects for Oracle exists already. (using proc compiler for Oracle)
    I am adding additional rules for compiling SQL source into object files for TT ( making use of ectt extension, and using the proc compiler for TT)
    3. Combine objects into libraries,
    Create library libxx_ora.so based on  xx_ora.o objects 
    Create library libxx_tt.so based of  xx_tt.o objects
    4. Linking the application: We need 2 copies of the application (because use of TimesTen is optional for our customers, the build needs to produce binaries for both Oracle-only and Oracle+TimesTen):
    For oracle-only support: link with libxx_ora.so libraries (+ other libraries)
    For oracle+timesTen support: link with libxx_tt.so libraries (+ other libraries)
    We have scripts and makefiles that manage all of our system builds.
    I have extended the initial environment setup to now also include environment settings for TimesTen.
    I find that there seems to be a conflict when running the Proc*C TimesTen compiler, while also having the environment set for Oracle (core dump during proc-processing). Is this a known limitation?
    Now I am questioning whether I can do all of the system-build for oracle and TT in one pass (e.g. setup environment, followed by building of all objects)
    I may have to divide the build tasks up into two parts, separatig Oracle and TT object creation ?
    1) establish environment for TT only – compile all the TT-related source files
    2) as a second step change environment to Oracle only then compile all Oracle-related source files.
    Is anyone else facing the same conflict of oracle/TimesTen during compilation of Embedded SQL sources?
    M

    This is really the same situation as if you were trying to build different binaries using different versions of Pro C (which is in fact what you are trying to do). The Pro C compilation system is quite complex and it uses a lot of environment variables and so on. You really need to isolate both build environments so that each environment only has the necessary environment setup and there is no cross-contamination between them.
    Chris

Maybe you are looking for

  • How to sort files in a PDF binder by date4

    I created a portfolio for my paycheck stubs I would like them sorted by date, in reverse, meaning the latest date appears first I cannot drag them into the order I want. Why can I not drag files? I tried renaming all the files with numbers so they ap

  • Adobe PDF IFilter for document searches does not work

    I am new to full text indexing of documents but I know enough to get the files into the database and apply indexing and searches because I got it to work for Word (.doc) files.   I'm trying to get Adobe's Ifilter version 11 to work in Windows 7 x64. 

  • Need help on Pearl 9100!!!

    Hello I have recently taken Pearl 9100 and i am unable to play the video files share through BBM. The error message i get is "File format not supported" Can anyone help me what does it mean? Do i need to install any video player?  Please help. Thanks

  • Error: f14627469cba51.pdf file is too large for attachment

    Hi, Recently we migrated lot of crystal reports from BO XI R2 environment to BO 3.1 SP2 FP 2.5 environment, these crystal reports are integrated with the application. Input parameters are given through the application using the Open Document URL and

  • Placing a plug-in

    Down loaded a plug-in and want to try it out within Logic. Where do you put it?