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 5 of 5

Thread: Sending data from a computer to a server autonomously(spelling?)

  1. #1
    Member
    Join Date
    Oct 2010
    Location
    Denver, CO
    Posts
    55
    Thanks
    1
    Thanked 30 Times in 29 Posts

    Default Sending data from a computer to a server autonomously(spelling?)

    What is the best method to accomplish getting data from my computer to a server so that I can then view it in a applet in a browser?

    I have a sensor attached to my computer, I already have that all done and good and saving the data to a text file( it does close the file stream inbetween writes), I want the data to be updated to a server every 5 minutes or so, I was thinking it might be best to write a little program that just listens for a connection on port #### and if it gets it it takes any incoming data and writes it into a txt file on the server, run that on the server and a write a client that just tries connect and send the txt file every 5 min, is there a better way to do this?

    Would this probably use little enough bandwidth to just keep the connection to the server running all the time and send each data I get(about every 5 seconds) line by line, or lump it into 5 minute updates of 60 lines at once? It is just temperature data, so the time between updates doesn't really matter since it shouldn't change much in 5 min, so really which ever is more reliable is preferred.

    I already have an applet made to display the data also, just need to get that txt file onto the server without me.


  2. #2
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,042
    Thanks
    63
    Thanked 2,708 Times in 2,658 Posts

    Default Re: Sending data from a computer to a server autonomously(spelling?)

    Have you looked at using the Socket and ServerSocket classes?

  3. #3
    Junior Member
    Join Date
    Nov 2010
    Posts
    18
    Thanks
    0
    Thanked 2 Times in 2 Posts

    Default Re: Sending data from a computer to a server autonomously(spelling?)

    Here is a simple tutorial on how to do that.

    A Simple Java TCP Server and TCP Client | systemBash

    And I think that is what you looking for, and one another thing, you must always start server side code because when client requesting from server, if server do not respond it will throw an exception.

  4. The Following User Says Thank You to isuru For This Useful Post:

    Zula (February 7th, 2012)

  5. #4
    Member
    Join Date
    Oct 2010
    Location
    Denver, CO
    Posts
    55
    Thanks
    1
    Thanked 30 Times in 29 Posts

    Default Re: Sending data from a computer to a server autonomously(spelling?)

    Cool, and I won't ask for C advice here, but there are no problems with writing a server in C and a client in Java are there? As long as the port is the same and all that good shtuff?

  6. #5
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,042
    Thanks
    63
    Thanked 2,708 Times in 2,658 Posts

    Default Re: Sending data from a computer to a server autonomously(spelling?)

    One possible difference could be with int data. The order of the bytes could be different.

Similar Threads

  1. connection to a database on another computer(server)
    By myke in forum JDBC & Databases
    Replies: 12
    Last Post: May 31st, 2012, 03:09 AM
  2. sending images client/server sockets
    By devett in forum Java Networking
    Replies: 7
    Last Post: June 7th, 2011, 08:38 AM
  3. Sending zip from server socket
    By moon_werewolf in forum Java Theory & Questions
    Replies: 0
    Last Post: May 30th, 2011, 07:51 AM
  4. sending objects from client to server
    By 11moshiko11 in forum What's Wrong With My Code?
    Replies: 16
    Last Post: October 8th, 2010, 04:47 AM
  5. Replies: 6
    Last Post: September 19th, 2010, 08:33 PM