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

Thread: Problem with socket.receive

  1. #1
    Junior Member
    Join Date
    Sep 2013
    Posts
    20
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default Problem with socket.receive

    Hi, some days ago I posted about a web aplication for send and udp command to a GPS, now I can do it, but Im having a problen with the code for get the incomming messages just with socket.receive, I hope someone can help me to solve that. Thanks.

    If I remove socket.setSoTimeout then the program never end.

    here the link of the old thread: Send Hex data in a UDP frame

    and here my java code now:


  2. #2
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    SW Missouri
    Posts
    20,376
    Thanks
    49
    Thanked 2,208 Times in 2,181 Posts

    Default Re: Problem with socket.receive

    How long do you want the program to wait before it decides that it is not going to receive a message?
    If you don't understand my answer, don't ignore it, ask a question.

  3. #3
    Junior Member
    Join Date
    Sep 2013
    Posts
    20
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default Re: Problem with socket.receive

    Quote Originally Posted by Norm View Post
    How long do you want the program to wait before it decides that it is not going to receive a message?
    the device responds almost instantly. I think after 5sec.

  4. #4
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    SW Missouri
    Posts
    20,376
    Thanks
    49
    Thanked 2,208 Times in 2,181 Posts

    Default Re: Problem with socket.receive

    Can you explain what the problem is?
    If you don't understand my answer, don't ignore it, ask a question.

  5. #5
    Junior Member
    Join Date
    Sep 2013
    Posts
    20
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default Re: Problem with socket.receive

    the socket.receive(receivePacket); doesn't work, the application stop at this point. its important for me get the message but thats not working, i cant read the incomming message.

    I get this message in the eclipse console: at java.net.DatagramSocket.receive(Unknown Source)

  6. #6
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    SW Missouri
    Posts
    20,376
    Thanks
    49
    Thanked 2,208 Times in 2,181 Posts

    Default Re: Problem with socket.receive

    If that is an error message, you need to copy the FULL text and paste it here.

    Do you have a program for testing in place of the GPS device?
    If you don't understand my answer, don't ignore it, ask a question.

  7. #7
    Junior Member
    Join Date
    Sep 2013
    Posts
    20
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default Re: Problem with socket.receive

    Im using hercules in another computer.

    You mean, copy the full text of the error?

  8. #8
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    SW Missouri
    Posts
    20,376
    Thanks
    49
    Thanked 2,208 Times in 2,181 Posts

    Default Re: Problem with socket.receive

    I would test the receive program with special testing software that simulated the GPS to see if it would send and receive messages as expected.
    I know nothing about hercules.
    If you don't understand my answer, don't ignore it, ask a question.

  9. #9
    Junior Member
    Join Date
    Sep 2013
    Posts
    20
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default Re: Problem with socket.receive

    did u test it? I continue with same problem

  10. #10
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    SW Missouri
    Posts
    20,376
    Thanks
    49
    Thanked 2,208 Times in 2,181 Posts

    Default Re: Problem with socket.receive

    How can I test it? Do you have code to simulate the GPS?
    If you don't understand my answer, don't ignore it, ask a question.

  11. #11
    Junior Member
    Join Date
    Sep 2013
    Posts
    20
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default Re: Problem with socket.receive

    not really, I have to do it with the GPS, but I can give you the IP and port from the device in a PM.

  12. #12
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    SW Missouri
    Posts
    20,376
    Thanks
    49
    Thanked 2,208 Times in 2,181 Posts

    Default Re: Problem with socket.receive

    You could write some testing software to simulate the GPS to use with the program for testing to look for some first level bugs.
    Have you communicated with the GPS with any software?
    If you don't understand my answer, don't ignore it, ask a question.

  13. #13
    Junior Member
    Join Date
    Sep 2013
    Posts
    20
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default Re: Problem with socket.receive

    I was using Hercules before

  14. #14
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    SW Missouri
    Posts
    20,376
    Thanks
    49
    Thanked 2,208 Times in 2,181 Posts

    Default Re: Problem with socket.receive

    Sorry, I don't know anything about Hercules.
    If you don't understand my answer, don't ignore it, ask a question.

Similar Threads

  1. [Problem] Receive video stream from the net
    By Branca94 in forum Java Theory & Questions
    Replies: 6
    Last Post: April 17th, 2013, 01:16 AM
  2. Socket Problem?
    By danza in forum What's Wrong With My Code?
    Replies: 0
    Last Post: June 10th, 2012, 02:22 AM
  3. Problem with Receive SMS in WindowsMobile
    By dr_jacky_2005 in forum Java ME (Mobile Edition)
    Replies: 0
    Last Post: August 16th, 2011, 07:01 AM
  4. Socket problem
    By Robtn in forum What's Wrong With My Code?
    Replies: 11
    Last Post: June 15th, 2011, 03:50 PM
  5. Send and Receive data from socket simultaneously
    By bigmac025 in forum File I/O & Other I/O Streams
    Replies: 0
    Last Post: March 25th, 2011, 05:18 PM