This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes Sockets and Internet Protocols and the fly likes I am sending my UDP but can not receive Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Sockets and Internet Protocols
Bookmark "I am sending my UDP but can not receive" Watch "I am sending my UDP but can not receive" New topic
Author

I am sending my UDP but can not receive

Joldas Nursoltan
Greenhorn

Joined: Mar 04, 2006
Posts: 10
am sending my simple string values as UDP data from my pc to another pc(both we have proper java envroment and correct code) and vice versa, but either me and he can not receive the udp. my(and his) port forever waitng with loops from the udp data each of our pc, when other side send me, it can not received....all same port..

but when i send and receive local pc, it is no problem....

what's the problem here?




i need help in java!!!
Jon Avadis
Ranch Hand

Joined: Jul 20, 2011
Posts: 49

Hi

Do you have a piece of code to receive the packet?

Something like




Because in the code you posted, you only send a packet and then close the socket. Theres no receiving going on...


Knowledge Reigns Supreme
Joldas Nursoltan
Greenhorn

Joined: Mar 04, 2006
Posts: 10
Jon Avadis wrote:Hi

Do you have a piece of code to receive the packet?

Something like




Because in the code you posted, you only send a packet and then close the socket. Theres no receiving going on...




hello,

there are receiving code:



then, please, give me the solution..

thank you...
Todd Buell
Greenhorn

Joined: May 31, 2005
Posts: 21
When you are sending in the displayed code you are sending to port 7776. When you listen on the remote system, are you listening on the correct port?
Joldas Nursoltan
Greenhorn

Joined: Mar 04, 2006
Posts: 10
Todd Buell wrote:When you are sending in the displayed code you are sending to port 7776. When you listen on the remote system, are you listening on the correct port?


sorry., it is same port.

although that i still can not listen...
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19649
    
  18

Moving to our Sockets / Internet Protocols forum.


SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6
How To Ask Questions How To Answer Questions
Joldas Nursoltan
Greenhorn

Joined: Mar 04, 2006
Posts: 10
any solutions?

or need any udp hole punching?

pzl, help me.......thanks
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19649
    
  18

Sorry to nitpick, but UseRealWords: "please", not "pzl".
Karthik Shiraly
Ranch Hand

Joined: Apr 04, 2009
Posts: 489
    
    5
Joldas Nursoltan wrote:any solutions?

or need any udp hole punching?

pzl, help me.......thanks


- Is the sender on the same subnet as the receiving machine? Sender IP address should be something like 124.126.176.x if subnet is 255.255.255.0. Normally, routers are configured to prevent UDP across subnets.

- If you have multiple network interfaces on the receiving machine, then perhaps InetAddress.getLocalHost() is resolving to a IP address on another network interface than the one you're sending to. Check value returned by getLocalHost().

- If both are ok, then perhaps one or both machines have firewalls preventing traffic on that subnet and port?
Joldas Nursoltan
Greenhorn

Joined: Mar 04, 2006
Posts: 10
Karthik Shiraly wrote:
Joldas Nursoltan wrote:any solutions?

or need any udp hole punching?

pzl, help me.......thanks


- Is the sender on the same subnet as the receiving machine? Sender IP address should be something like 124.126.176.x if subnet is 255.255.255.0. Normally, routers are configured to prevent UDP across subnets.

- If you have multiple network interfaces on the receiving machine, then perhaps InetAddress.getLocalHost() is resolving to a IP address on another network interface than the one you're sending to. Check value returned by getLocalHost().

- If both are ok, then perhaps one or both machines have firewalls preventing traffic on that subnet and port?


thank you...
NAT = Network address translation

1- i am and the remote computer are not under the same NAT, he is on another different NAT on the another city...the sende and receiver not LAN; local area network....

2 - my address.getHostAddress() printed 192.168.0.101, not printed real ip address as above,....

i am and he is also unabled firewall, then tried...but does not work...

i am waiting any response....thank you

Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18541
    
    8

Joldas Nursoltan wrote:1- i am and the remote computer are not under the same NTA, he is on another different NTA on the another city...the sende and receiver not LAN; local area network....


I'm sorry, I don't really understand that. But if it means you are trying to send UDP over the internet, then no, that isn't going to work.
Joldas Nursoltan
Greenhorn

Joined: Mar 04, 2006
Posts: 10
Paul Clapham wrote:
Joldas Nursoltan wrote:1- i am and the remote computer are not under the same NTA, he is on another different NTA on the another city...the sende and receiver not LAN; local area network....


I'm sorry, I don't really understand that. But if it means you are trying to send UDP over the internet, then no, that isn't going to work.


yes, send onver internet, between any computer on the internet, example, from you to me, or frm me to you...
 
 
subject: I am sending my UDP but can not receive
 
Similar Threads
Datagram encoding help needed!
Broadcasting to addresses
Communicate 2 android in 2 emulator
Pinger time!
Simple problem in running a Server class