Skip to contentSkip to conversation

Getting the IP address of a UDP client

DISCUSSION Lee Chin 5 participants 6 messages Jan 3, 2003 – Jan 5, 2003

lore
Share & tools
lore

Lee Chin

author
#0 lore raw

Hi
I can use getpeername to get the IP address of a client on a connected TCP socket, but when I have a UDP client that just sent me a packet, how do I get the IP address of that UDP client?

Thanks
Lee

__________________________________________________
Do you Yahoo!?
Yahoo! Mail Plus - Powerful. Affordable. Sign up now.
http://mailplus.yahoo.com
-
To unsubscribe from this list: send the line "unsubscribe linux-newbie" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.linux-learn.org/faqs

#1 lore raw
Quoted 4 lines · Lee Chin

I can use getpeername to get the IP address of a client on a connected TCP socket, but when I have a UDP client that just sent me a packet, how do I get the IP address of that UDP client?

Forgive me if I have misunderstood you, but do you use accept() to create the new incoming connection? Then the second argument to accept() is a structure, which contains the information you want.

Have a look at the man page of accept(2).

Elias

Signature · 6 lines
http://gnewtellium.sourceforge.net			MP3 is not a crime.	
-
To unsubscribe from this list: send the line "unsubscribe linux-newbie" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.linux-learn.org/faqs
author
#2 lore raw

Hi,
This is a UDP server ... so I do not use accept, I simply have a server loop that does a "recv" ...

So the server does a recvfrom and then a sendto on the same file descriptor...

When I try to do an accept, that system call fails because it is not a TCP socket...

Thanks
Lee

Quoted 16 lines · --- Elias Athanasopoulos
Quoted 2 lines · Lee Chin

I can use getpeername to get the IP address of a
client on a connected TCP socket, but when I have

a

Quoted 1 line

UDP client that just sent me a packet, how do I

get

Quoted 1 line

the IP address of that UDP client?

Forgive me if I have misunderstood you, but do you use accept() to create
the new incoming connection? Then the second argument to accept() is
a structure, which contains the information you want.

Quoted 7 lines

Have a look at the man page of accept(2).

Elias

Signature · 2 lines
http://gnewtellium.sourceforge.net			MP3 is not a
crime.	

__________________________________________________
Do you Yahoo!?
Yahoo! Mail Plus - Powerful. Affordable. Sign up now.
http://mailplus.yahoo.com
-
To unsubscribe from this list: send the line "unsubscribe linux-newbie" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.linux-learn.org/faqs

#4 lore raw

Re: digest?

Hi Jonathan
I haven't found one.
If anyone knows of one I hope they answer to the list. Lorraine

Quoted 9 lines · Jonathan Kallay

Is there a way to get a daily digest from this mailing list, instead of getting each message individually?

-
To unsubscribe from this list: send the line "unsubscribe linux-newbie" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.linux-learn.org/faqs

-
To unsubscribe from this list: send the line "unsubscribe linux-newbie" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.linux-learn.org/faqs

#5 lore raw

Re: digest?

This list is pretty much ignored by the folks who run things at vger, so I doubt you'll get an authoritative answer to this question. But in my several years on this list, I've never seen any mention of a digest version.

OTOH, and to my surprise, I jusr discovered that there are two archives of the list. They are listed at

http://vger.kernel.org/vger-lists.html

in the section on linux-newbie. The Sourceforge one is not current, but the other one is up to date. I suppose that is an anternative for people who find the individual messages to consritute too much traffic. Beware, though ... my expeirnec is that list archives for this list come and go, unpredictably.

Of course, I could be wrong.

Quoted 9 lines · LL Phillips

Hi Jonathan
I haven't found one.
If anyone knows of one I hope they answer to the list. Lorraine

Quoted 3 lines · Jonathan Kallay

Is there a way to get a daily digest from this mailing list, instead of getting each message individually?

--
-------------------------------------------"Never tell me the odds!"--------
Ray Olszewski -- Han Solo
Palo Alto, California, USA [email protected]
-------------------------------------------------------------------------------

-
To unsubscribe from this list: send the line "unsubscribe linux-newbie" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.linux-learn.org/faqs