Hello, I have used socketConnection to connect to a TCP server. I havent figured out a way to do the same with a UDP server. i.e I have a server listening on 9000, communicating via UDP. I would like to , from R, send packets to this server, This does not work u <- socketConnection('localhost',9000) Error in socketConnection("localhost", 9000, blocking = F) : cannot open the connection In addition: Warning message: In socketConnection("localhost", 9000, blocking = F) : localhost:9000 cannot be opened I have confirmed that something is indeed listening on the other side. Any help would be appreciated. Regards Saptarshi
Saptarshi Guha wrote:> > This does not work > u <- socketConnection('localhost',9000)UDP and TCP are entirely different worlds. They don't share the same port space; TCP port 9000 and UDP port 9000 are different things. Plus, UDP is connectionless, so you can't "connect" to a UDP port. All you can do is throw packets at a server, which may or may not be listening for those packets. You will either have to rely on an external program to do the UDP communication for you, or write an extension to R to provide this functionality. Suitable helper programs are 'nc' and 'ncat'. nc is abandonware, so the nmap folk built their own version of the same idea and added it to nmap v5. nmap v5 is very new, though, so you might have nc on your system already, but and old version of nmap, and prefer to use the defunct program rather than upgrade your nmap.