Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 4 of 4

Thread: Unsure where to start with networking

  1. #1
    Junior Member
    Join Date
    May 2012
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Unsure where to start with networking

    Hi everyone, I'm trying to create two apps, one would go onto a client, another on a server. I want to be able to send information from the server to the client over the internet. Tell me if I'm wrong, but I'm operating under the assumption that my computer can act as a server just by being on, and having the server program running.

    I've been reading up on this subject, and so far 2 subjects stick out: URL's and sockets. Sockets seem to be used only over a network (LAN), and URL's are for getting resources (its in the name!), i.e.: files off the server. I don't want to send files, I only want to send small amounts of data from the server to the client periodically (like, send an 'int' value from one machine to another, no files or anything). Problem is, every tutorial I read seems to only talk about getting this to work over a network, or just talks about accessing files on the host machine, some involve cgi scripts, which make me think that I'm on the wrong track.


  2. #2
    Forum VIP
    Join Date
    Jul 2010
    Posts
    1,676
    Thanks
    25
    Thanked 329 Times in 305 Posts

    Default Re: Unsure where to start with networking

    So you want an Applet (or Application) and a Servlet, right? Personally, I don't know too much about Servlets, but if that is what you are after, it might make your searching easier to know the terminology for what you are trying to do.
    NOTE TO NEW PEOPLE LOOKING FOR HELP ON FORUM:

    When asking for help, please follow these guidelines to receive better and more prompt help:
    1. Put your code in Java Tags. To do this, put [highlight=java] before your code and [/highlight] after your code.
    2. Give full details of errors and provide us with as much information about the situation as possible.
    3. Give us an example of what the output should look like when done correctly.

    Join the Airline Management Simulation Game to manage your own airline against other users in a virtual recreation of the United States Airline Industry. For more details, visit: http://airlinegame.orgfree.com/

  3. #3
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,139
    Thanks
    65
    Thanked 2,720 Times in 2,670 Posts

    Default Re: Unsure where to start with networking

    There are lots of server/client code on the forums. Do a search for ServerSocket for some samples.

    You can write code using ServerSockets to handle responses to paths represented by URLs.
    Socket can be used for sending requests to servers.
    If you don't understand my answer, don't ignore it, ask a question.

  4. #4
    Junior Member
    Join Date
    May 2012
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: Unsure where to start with networking

    I've had some success, I just wanted to share it with any lurkers out there.
    This tutorial: Building an Internet chat system - JavaWorld

    It involves ServerSockets, I compiled/ran the client on one comp, and the server on the other one, and I'm able to connect, by providing the name of the host computer on the network (they're connected to the same router). To see if I could theoretically do this remotely, I set up the router to use a "virtual server", so that anything entering on a certain port would be re-routed to the host computer (whose server app uses that port). I had the client use the ip address of the router (google: "my ip") and the same port.
    I've yet to test this on an actually remote system. Not the most user-friendly solution, either, but its a start! (I think)

Similar Threads

  1. Networking asignment
    By Ralbeyd in forum Totally Off Topic
    Replies: 1
    Last Post: February 1st, 2012, 06:28 AM
  2. Game Networking
    By Parsnips in forum Java Networking
    Replies: 15
    Last Post: December 1st, 2011, 02:57 PM
  3. [SOLVED] java networking
    By renu1 in forum Java Networking
    Replies: 0
    Last Post: March 12th, 2010, 12:33 PM
  4. In a bit of a pickle, unsure of what I should do
    By MysticDeath in forum What's Wrong With My Code?
    Replies: 16
    Last Post: October 31st, 2009, 09:10 AM
  5. :!! Unsure how to set this up/ Still learning java loops!!!!!
    By raidcomputer in forum Loops & Control Statements
    Replies: 4
    Last Post: September 29th, 2009, 10:28 AM