Results 1 to 13 of 13
  1. #1
    skarosg3 is offline Member
    Join Date
    May 2010
    Posts
    20
    Rep Power
    0

    Default Client Server program, a tiny problem.

    Hi all,
    I made a client server program that is working like a charm(on a single computer).
    I happen to have a virtual machine on this computer and tried to load the client there and keep the server running on the host OS.
    I cant make the client to see the server. It might have to do with the fact that both OS have the same ip and when i try to connect to the server IP the client recognize that its own!

    Any way, the real question is this: Do i have to do anything else if the client and the server are not on the same network? all my previous client server programs were for academic reasons, and were all tested in a lab, but now i dont have a second computer on my network, so i cant even test it within the same network.

    any help pls?
    thanks ilias
    Last edited by skarosg3; 05-26-2010 at 06:54 PM.

  2. #2
    gcalvin is offline Senior Member
    Join Date
    Mar 2010
    Posts
    953
    Rep Power
    5

    Default

    Even in a virtualized environment, your host and guest should have separate IP addresses. Take another look at that.

    -Gary-

  3. #3
    skarosg3 is offline Member
    Join Date
    May 2010
    Posts
    20
    Rep Power
    0

    Default

    It is the same! Honestly. I just realized that i didnt mention that i am talking about the global IP, not the local one. It is normal to have both computers the same global IP, since there is only one ip for the network.
    If you are talking about the local ip, yes, they do have different ones, but i wanted to check it with the global, so i can make sure that when i give the client program to be tested that it will work ok.

  4. #4
    gcalvin is offline Senior Member
    Join Date
    Mar 2010
    Posts
    953
    Rep Power
    5

    Default

    We're getting a bit out of scope for a Java forum here...

    Your terms global and local are not clear to me. The host OS has an IP address visible from the external network -- I guess that's the one you're calling "global". The guest OS will have its own IP address. It does not have the same IP address as the host, and should not be confused by the host's IP. This is true whether you're running a NAT, bridged, or host-only configuration. If you're configured for NAT or bridging, you should be able to use the host's external IP address, but if you're configured host-only, you may need to reference the host's internal IP instead (possibly for NAT as well, depending on firewall settings).

    -Gary-

  5. #5
    skarosg3 is offline Member
    Join Date
    May 2010
    Posts
    20
    Rep Power
    0

    Default

    I thought that global and local ip were commonly used. sorry for not determine what i meant. Yes, by global i mean (and is) the ip of the network to the outside world. Local ip is the within the network ip.
    I did try and used the local ip of the host OS and it did work just fine. but that is not going to help me at all if someone else from an other network tries to run the client! There they will need the global ip.

    The problem is that i am not sure how to search for the solution on the web. i am getting so many stupid results.
    I might just use a dns program that would give me a fake static ip.

  6. #6
    gcalvin is offline Senior Member
    Join Date
    Mar 2010
    Posts
    953
    Rep Power
    5

    Default

    I don't think you have a real problem here. As long as your host is listening on both IP addresses, your service should work fine on both. Accessing it from the client in the VM was for testing purposes, right? Those tests are valid, and the only untested issue would be firewalling on the external host IP. You should be able to figure that out quickly as soon as you get another client trying to connect from outside.

    Or maybe you are asking about how to make sure your server process listens on all IP addresses?

    -Gary-

  7. #7
    skarosg3 is offline Member
    Join Date
    May 2010
    Posts
    20
    Rep Power
    0

    Default

    Quote Originally Posted by gcalvin View Post
    Or maybe you are asking about how to make sure your server process listens on all IP addresses?
    That was my main concern, making sure that my server can listen to connections outside my network. Thats why i tried to use my global ip instead of my 192.168....
    i guess i will have to just give the client to someone else in order to find out if it is working or not. after i solve the new problem, that i am getting an error from my virtual OS client for the mysql connection!
    I will not change the subject of the thread now, it has nothing to do with networking anyway, i just dont get it, how it can work on localhost, but not in network! i am getting an jdbc connection error. will search about it.
    thanks

  8. #8
    gcalvin is offline Senior Member
    Join Date
    Mar 2010
    Posts
    953
    Rep Power
    5

    Default

    If I understand what you're trying to do at all, your client should not be trying to make any SQL connections. Only the server should connect to a database.

    -Gary-

  9. #9
    skarosg3 is offline Member
    Join Date
    May 2010
    Posts
    20
    Rep Power
    0

    Default

    funny that you mention that. I was thinking about it when i started this, but wasnt, and still am not, sure if this is the best way to do it. i wasnt going to ask this, cos i made a decision and was going to stick to it, but as part of the conversation i could ask for your opinion.

    The thing is that the application i am doing, is going to be used from ppl whose background i dont know. Basiclly it is a school system that will allow teachers to access pupils info. my main problem is that they wanted the information passed to the users to be easily changed depending on the needs.
    I thought 3 different ways of doing it:
    There are only client machines that connect to the mysql server and download tables, stored procedures and everything the admin stores on the server. That even though is the easiest for me, would imply that the admin will have to work on the database on his own. The problem is that i dont know if he is able to do it. And in any case, even if he is able, you never know when this teacher is going to be fired and an other teacher comes that has no idea about databases.
    So an application that would connect to the database and create new queries and whatever came to my mind, creating the next dilemma, should all client request pass through this application or not. I decided against it cos it would just create extra traffic to my server. So what i am doing now is that the clients will connect to the server, get all the information they need about the database, the new data that they can work on(new queries, forms etch) and then connect to the database server and work independently from the application server that i wrote.

    I honestly dont know which of the 3 would be the best solution for this case. Defenetly it would be best to just have the clients with out any server, but just in one in a million the new teacher that comes along has no idea about mysql? then what? the system will just sit there with no updates and no new information.

    Let alone that i decided to use mysql instead of my favorite(for this kind of jobs) postgreSQL just in case they decide to move the database to some king of php application. Mysql (or at least the client application that i downloaded) seems to me so difficult to use. i run simple queries and create commands and i am getting errors that make no sense, referring me to the manual!

    I know that this is completely irrelevant to the post and to the scope of this forum, but i just took the opportunity to place my thoughts.

    ilias

  10. #10
    gcalvin is offline Senior Member
    Join Date
    Mar 2010
    Posts
    953
    Rep Power
    5

    Default

    Well, this is application design, so I don't think it's off-topic or out of scope. And please excuse me for being blunt -- understand that it's just my opinion, and make of it what you will.

    First of all, I'm mystified why you'd go with MySQL. I agree that PostgreSQL is superior, and it has plenty of PHP support. But maybe this is something the client insisted on.

    What you're describing, if I understand it correctly, is a client that requires two connections to the server. There's the socket connection for downloading code, updates, configurations and the like, and then there's a separate database connection. So all clients do still share a common database? Or do they each have a local database? Are all the clients at the same physical site?

    -Gary-

  11. #11
    skarosg3 is offline Member
    Join Date
    May 2010
    Posts
    20
    Rep Power
    0

    Default

    Quote Originally Posted by gcalvin View Post
    And please excuse me for being blunt -- understand that it's just my opinion, and make of it what you will.
    I have no problem at all listening to some other opinion. thats why i brought it up.

    Quote Originally Posted by gcalvin View Post
    First of all, I'm mystified why you'd go with MySQL. I agree that PostgreSQL is superior, and it has plenty of PHP support. But maybe this is something the client insisted on.
    No, he did not mention any dbms. it could be access for all they care. i just think that mysql is the most commonly used for web applications. so if they decide later on that this java app is no good and would prefare to have it on a web server, they woulnt have to change to mysql from prostrgesql. I should say here that i have no clue about web applications and i couldnt care less, but i thought it would be a proper design for future development.

    Quote Originally Posted by gcalvin View Post
    What you're describing, if I understand it correctly, is a client that requires two connections to the server. There's the socket connection for downloading code, updates, configurations and the like, and then there's a separate database connection.
    Yes

    Quote Originally Posted by gcalvin View Post
    So all clients do still share a common database? Or do they each have a local database? Are all the clients at the same physical site?
    I havent thought about having each client a local database. why would they have one? there would be so many other problems then from the way i see it. synchronization, change of the same fields by 2 clients etch...

    Quote Originally Posted by gcalvin View Post
    Are all the clients at the same physical site?
    What do u mean physical site? the app is supposed to give access to teacher in order to be able from home to see and change the students information. So the clients will be on each teacher's home or maybe on school's campus.

  12. #12
    gcalvin is offline Senior Member
    Join Date
    Mar 2010
    Posts
    953
    Rep Power
    5

    Default

    OK, I think I understand better now. I would be quite concerned with having multiple direct MySQL connections over the public Internet. Unless you really, really, really know what you're doing, it's a pretty serious security risk. It's much safer for clients to connect only to your server app, and for it to maintain a single connection to the database. I wouldn't be quite so concerned if the server and all clients were all in the same physical building, on the same private network, but connecting from various locations to the database over the public Internet... I just couldn't be comfortable with that.

    I agree that trying to have a separate database for each client would be even worse. I just wanted clarification on that.

    If you're not too far down the road, I would switch back to PostgreSQL. Even if they want to use it with a web app someday, they shouldn't have any trouble, and the license is better for this situation too. (I have no problem with GPL, and I use lots of GPL software, but in this situation, I think PostgreSQL's BSD-style license is a better fit.)

    Don't worry about additional traffic. It doesn't sound like it would be significantly more anyway, and it's not as if you're moving hour-long video files around, right? Unless you have a much larger user population than I'm guessing you have, traffic will not be an issue.

    I don't know how tight your deadline is, how complex the app is, or what your skills are, but I think you should take a look at Google Web Toolkit.

    Google Web Toolkit - Google Code

    Essentially, you write your code in Java, and GWT "compiles" it into cross-platform JavaScript that runs in a web browser. It's not all of Java, but it's a very useful subset, and there's a rich collection of user interface widgets. The big advantage of this approach is that there is no client-side app to deploy, but you still get the rich functionality of a Java client. If you've ever used Google Mail or Google Apps then you have an idea of what can be done. It's free and open source.

    You probably would still need to do a client-server design, with a true Java server doing the database interaction, but GWT has plenty of features to make that easy and straightforward.

    Take it for what it's worth. :)

    -Gary-

  13. #13
    skarosg3 is offline Member
    Join Date
    May 2010
    Posts
    20
    Rep Power
    0

    Default

    Quote Originally Posted by gcalvin View Post
    OK, I think I understand better now. I would be quite concerned with having multiple direct MySQL connections over the public Internet. Unless you really, really, really know what you're doing, it's a pretty serious security risk. It's much safer for clients to connect only to your server app, and for it to maintain a single connection to the database. I wouldn't be quite so concerned if the server and all clients were all in the same physical building, on the same private network, but connecting from various locations to the database over the public Internet... I just couldn't be comfortable with that.
    I was thinking about that my self, i just thought that the security of mysql would be enough. I could alter my server to accept all traffic and just re-route it to the database.

    Quote Originally Posted by gcalvin View Post
    I agree that trying to have a separate database for each client would be even worse. I just wanted clarification on that.

    If you're not too far down the road, I would switch back to PostgreSQL. Even if they want to use it with a web app someday, they shouldn't have any trouble, and the license is better for this situation too. (I have no problem with GPL, and I use lots of GPL software, but in this situation, I think PostgreSQL's BSD-style license is a better fit.)
    i havent done so much work. i have been working on it for the last 3 days or so. i might switch to postgresql after all. Its nice to know that i am not alone with my mysql opinion:)

    Quote Originally Posted by gcalvin View Post
    Don't worry about additional traffic. It doesn't sound like it would be significantly more anyway, and it's not as if you're moving hour-long video files around, right? Unless you have a much larger user population than I'm guessing you have, traffic will not be an issue.
    true
    Quote Originally Posted by gcalvin View Post
    I don't know how tight your deadline is, how complex the app is, or what your skills are, but I think you should take a look at Google Web Toolkit.

    Google Web Toolkit - Google Code

    Essentially, you write your code in Java, and GWT "compiles" it into cross-platform JavaScript that runs in a web browser. It's not all of Java, but it's a very useful subset, and there's a rich collection of user interface widgets. The big advantage of this approach is that there is no client-side app to deploy, but you still get the rich functionality of a Java client. If you've ever used Google Mail or Google Apps then you have an idea of what can be done. It's free and open source.

    You probably would still need to do a client-server design, with a true Java server doing the database interaction, but GWT has plenty of features to make that easy and straightforward.

    Take it for what it's worth. :)

    -Gary-
    I have never used gwt b4, i first heard about it a year ago or so, but never got the chance to use it. Actually i downloaded it yesterday, even installed eclipse, since i noticed that it is easier to use and install gwt on eclipse than on netbeans that i am using. That was the reason really to install eclipse, i didnt want to spend half a day trying to install something that i wasnt sure i would use.
    Anyway, i tried to do the first turoria on gwt(something about stock prices or something) but i really couldnt see what is going on. to b honest, i didnt spend more than an hour on it, but it seemed quite complicated to set it up.
    I wanted to search for some other tutorial, in case it is different than the one from google but didnt get around to it just yet. i might now that you mention it as well.

Similar Threads

  1. Simple Client (2) - Server program
    By Reztem in forum New To Java
    Replies: 2
    Last Post: 01-09-2012, 02:05 AM
  2. about client to server problem
    By raywai in forum New To Java
    Replies: 3
    Last Post: 05-13-2010, 04:34 PM
  3. Multithreaded Client/Server Chat program
    By f0ns in forum Threads and Synchronization
    Replies: 3
    Last Post: 10-21-2009, 05:26 PM
  4. Replies: 2
    Last Post: 12-27-2008, 08:02 PM
  5. Replies: 0
    Last Post: 04-04-2008, 02:49 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •