LinuxQuestions.org
View the Most Wanted LQ Wiki articles.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices



Reply
 
Search this Thread
Old 03-21-2005, 08:14 AM   #1
cranium2004
Member
 
Registered: Feb 2004
Distribution: FC4,RHEL4
Posts: 223

Rep: Reputation: 30
how to get client ip address at udp server


I want to get client ip address at server side from whom i am receving UDP sockets connection and print it at server udp socket. How can i do that?
 
Old 03-21-2005, 10:32 PM   #2
papalukg
LQ Newbie
 
Registered: Dec 2003
Location: Patras
Distribution: slack
Posts: 4

Rep: Reputation: 0
Re: how to get client ip address at udp server

Quote:
Originally posted by cranium2004
I want to get client ip address at server side from whom i am receving UDP sockets connection and print it at server udp socket. How can i do that?
How do you receive packages?

If you are using receivfrom:
Code:
ssize_t recvfrom(int s, void *buf, size_t len, int flags, struct sockaddr
       *from, socklen_t *fromlen);
the struct sockaddr *from is filled with the client information, if it's not NULL. The sin_addr.s_addr field, should be field with the client IP.
 
Old 03-22-2005, 12:35 AM   #3
cranium2004
Member
 
Registered: Feb 2004
Distribution: FC4,RHEL4
Posts: 223

Original Poster
Rep: Reputation: 30
Hello,
Sorry for asking wrong and simple thing. actually i am interested in getting my local ethernet ip on which i receive
a socket data. I have eth0: 10.0.0.100 and eth1:192.168.1.100 then how to know on which i receive socket data. I know that
i only sending data from another pc eth:10.0.0.200 to 10.0.0.100. But how can i get that info in my udpServer.
I must have to set server socket with
servAddr.sin_family = AF_INET;
servAddr.sin_addr.s_addr = htonl(INADDR_ANY);
servAddr.sin_port = htons(LOCAL_SERVER_PORT);
then how t get my local IP?
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
How to get IP address of client from server.c program nazsarwat Programming 1 04-22-2005 04:57 PM
Network client not receiving address of DNS server arohl74 Linux - Networking 1 03-03-2005 07:58 AM
DHCP Server MAC Address found, IP address not assigned wmburke Linux - Wireless Networking 17 11-17-2004 11:33 AM
could not listen on UDP socket: address in use peaceofcrap2001 Linux - Networking 2 07-10-2004 01:18 PM
Server Client program using UDP frostmagic Programming 9 11-15-2003 12:06 AM


All times are GMT -5. The time now is 08:59 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration