LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
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 04-19-2005, 04:12 AM   #1
nazsarwat
LQ Newbie
 
Registered: Dec 2004
Location: pakistan
Posts: 1

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


hello,

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...

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

Rep: Reputation: 148Reputation: 148
From recvfrom man page:
Quote:
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.
 
  


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
[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


All times are GMT -5. The time now is 06:12 AM.

Main Menu
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