* Getting the IP address of a UDP client
@ 2003-01-03 18:43 Lee Chin
0 siblings, 0 replies; 5+ messages in thread
From: Lee Chin @ 2003-01-03 18:43 UTC (permalink / raw)
To: hahn, leechin, linux-newbie
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
--
__________________________________________________________
Sign-up for your own FREE Personalized E-mail at Mail.com
http://www.mail.com/?sr=signup
Meet Singles
http://corp.mail.com/lavalife
-
To unsubscribe from this list: send the line "unsubscribe linux-newbie" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.linux-learn.org/faqs
^ permalink raw reply [flat|nested] 5+ messages in thread
* Getting the IP address of a UDP client
@ 2003-01-03 19:03 Lee Chin
2003-01-04 0:13 ` Elias Athanasopoulos
0 siblings, 1 reply; 5+ messages in thread
From: Lee Chin @ 2003-01-03 19:03 UTC (permalink / raw)
To: hahn, linux-newbie
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 majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.linux-learn.org/faqs
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: Getting the IP address of a UDP client
2003-01-03 19:03 Lee Chin
@ 2003-01-04 0:13 ` Elias Athanasopoulos
2003-01-04 0:22 ` Lee Chin
0 siblings, 1 reply; 5+ messages in thread
From: Elias Athanasopoulos @ 2003-01-04 0:13 UTC (permalink / raw)
To: Lee Chin; +Cc: hahn, linux-newbie
On Fri, Jan 03, 2003 at 11:03:20AM -0800, Lee Chin wrote:
> 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
--
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 majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.linux-learn.org/faqs
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: Getting the IP address of a UDP client
2003-01-04 0:13 ` Elias Athanasopoulos
@ 2003-01-04 0:22 ` Lee Chin
0 siblings, 0 replies; 5+ messages in thread
From: Lee Chin @ 2003-01-04 0:22 UTC (permalink / raw)
To: Elias Athanasopoulos; +Cc: hahn, linux-newbie
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
--- Elias Athanasopoulos <eathan@otenet.gr> wrote:
> On Fri, Jan 03, 2003 at 11:03:20AM -0800, Lee Chin
> wrote:
> > 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
>
> --
> 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 majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.linux-learn.org/faqs
^ permalink raw reply [flat|nested] 5+ messages in thread
[parent not found: <Pine.LNX.4.44.0301031930470.29107-100000@coffee.psychology.mcmaster.ca>]
* Re: Getting the IP address of a UDP client
[not found] <Pine.LNX.4.44.0301031930470.29107-100000@coffee.psychology.mcmaster.ca>
@ 2003-01-04 2:26 ` Lee Chin
0 siblings, 0 replies; 5+ messages in thread
From: Lee Chin @ 2003-01-04 2:26 UTC (permalink / raw)
To: Mark Hahn; +Cc: Elias Athanasopoulos, linux-newbie
Hi Mark,
I am not using recvfrom... I simply use recv
In other words, I create the server UDP socket, listen
on a port then enter into a while loop just doing a
recv. Now the thing is, many different clients are
sending packets to the server, and I need to reply to
each of them at a later time, so I need to get their
IP addresses and store it away so I can do a sendto at
a later time
Thanks
Lee
--- Mark Hahn <hahn@physics.mcmaster.ca> wrote:
> > 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
>
> if you're using recvfrom, why aren't you simply
> providing
> a buffer for the "from" argument (and appropriate
> fromlen).
> read the fine man page!
>
__________________________________________________
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 majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.linux-learn.org/faqs
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2003-01-04 2:26 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2003-01-03 18:43 Getting the IP address of a UDP client Lee Chin
-- strict thread matches above, loose matches on Subject: below --
2003-01-03 19:03 Lee Chin
2003-01-04 0:13 ` Elias Athanasopoulos
2003-01-04 0:22 ` Lee Chin
[not found] <Pine.LNX.4.44.0301031930470.29107-100000@coffee.psychology.mcmaster.ca>
2003-01-04 2:26 ` Lee Chin
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox