Review your favorite Linux distribution.
Go Back > Forums > Non-*NIX Forums > Programming
User Name
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.


  Search this Thread
Old 04-19-2005, 04:12 AM   #1
LQ Newbie
Registered: Dec 2004
Location: pakistan
Posts: 1

Rep: Reputation: 0
How to get IP address of client from server.c program


I am using client server programming using UDP..the client sends message to server for a particular request

the server gets the ip address of client and based on its ip address server es certain values for the client from the mysql database...

I cannot find the exact code of finding ip address of client

can u please help me with the code.....

thanking u in advance...

Old 04-22-2005, 03:57 PM   #2
Registered: Feb 2002
Location: Grenoble
Distribution: Debian
Posts: 9,571

Rep: Reputation: 180Reputation: 180
From recvfrom man page:
ssize_t recvfrom(int s, void *buf, size_t len, int flags, struct sock-
addr *from, socklen_t *fromlen);

If from is not NULL, and the underlying protocol provides the source
address, this source address is filled in. The argument fromlen is a
value-result parameter, initialized to the size of the buffer associ-
ated with from, and modified on return to indicate the actual size of
the address stored there.
That's exactly what you need, IMHO.


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
[most secure, open source, client/server file transfer program] Synesthesia Linux - Software 5 11-28-2005 08:20 PM
how to get client ip address at udp server cranium2004 Programming 2 03-21-2005 11:35 PM
creating server socket program to handle multiple client at same time cranium2004 Programming 2 03-14-2005 10:58 AM
Network client not receiving address of DNS server arohl74 Linux - Networking 1 03-03-2005 06:58 AM
Server Client program using UDP frostmagic Programming 9 11-14-2003 11:06 PM > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 10:18 AM.

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