Win a copy of Cross-Platform Desktop Applications: Using Node, Electron, and NW.js this week in the JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

UDP connections in Java  RSS feed

 
thejaswini ramesh
Ranch Hand
Posts: 74
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi All,

I need to communicate to a device through UDP connection on port 161. I have written a very small bit of code to first start communication. But Im getting a java.net.BindException : Cannot assign requested address : Cannot Bind when I just create a DatagramSocket as below :



Can you please tell me how to establish the UDP connection or help me get rid of this exception?
 
Ulf Dittmer
Rancher
Posts: 42972
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I would guess that either the socket is already in use by another process, or that the account the JVM runs under is not allowed to bind to this socket (some OS -like Unix- don't allow non-root processes to bind to ports under 1024).
 
thejaswini ramesh
Ranch Hand
Posts: 74
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for the reply ,Ulf.

I am working on Windows Xp environment. I did'nt quite understand what you meant by :

some OS -like Unix- don't allow non-root processes to bind to ports under 1024


Can you please elaborate on that? What is the solution for this exception?
 
Ernest Friedman-Hill
author and iconoclast
Sheriff
Posts: 24217
38
Chrome Eclipse IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Since you're working on Windows, what Ulf said about UNIX doesn't matter.

Port 161 is used by the Windows SNMP agent; you'd have to disable that service to be allowed to listen on that port.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!