Getting IP address using UDP Socket

  • Thread starter jackster the jackle
  • Start date
J

jackster the jackle

Hi Ruby Forum...

I have a simple UDP Socket that I'm opening which listens for Syslog
messages on port 514.
I am receiving all syslog messages with no problem but I need to log
what IP address is sending the messages.
I have looked through the UDP Socket documentation but I can't seem to
figure out how to call it based on a received message from another host.
If anyone can help point me in the right direction, it would be greatly
appreciated....thanks.
Here is my working code:
Code:
server = UDPSocket.open
server.bind('0.0.0.0', '514')
while true do
syslog_message = server.recv(400)
server.addr
puts syslog_message
end

jackster
 
R

Robert Dober

Hi Ruby Forum...

I have a simple UDP Socket that I'm opening which listens for Syslog
messages on port 514.
I am receiving all syslog messages with no problem but I need to log
what IP address is sending the messages.
I have looked through the UDP Socket documentation but I can't seem to
figure out how to call it based on a received message from another host.
If anyone can help point me in the right direction, it would be greatly
appreciated....thanks.
Here is my working code:
Code:
server = UDPSocket.open
server.bind('0.0.0.0', '514')
while true do
[/QUOTE]
-        syslog_message = server.recv(400)
+      syslog_message, client_address = server.recvfrom(400)[QUOTE]
server.addr
puts syslog_message
end

jackster

HTH
Robert
 
J

jackster the jackle

you...sir, are a great man, sir......

thank you very much for helping me with that..it works perfectly.....

Where would I have looked to best be able to figure this out on my own
next time?

jackster



Robert said:
Here is my working code:
Code:
server = UDPSocket.open
server.bind('0.0.0.0', '514')
while true do
[/QUOTE]
-        syslog_message = server.recv(400)
+      syslog_message, client_address = server.recvfrom(400)[QUOTE]
server.addr
puts syslog_message
end

jackster

HTH
Robert
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,968
Messages
2,570,154
Members
46,702
Latest member
LukasConde

Latest Threads

Top