[VIEWED 5931
TIMES]
|
SAVE! for ease of future access.
|
|
|
i_my
Please log in to subscribe to i_my's postings.
Posted on 12-01-08 10:31
PM
Reply
[Subscribe]
|
Login in to Rate this Post:
0
?
|
|
need help with the C code. designing a proxy server. can't find a function that would return client IP address. help please.
|
|
|
|
sedif
Please log in to subscribe to sedif's postings.
Posted on 12-01-08 10:53
PM
Reply
[Subscribe]
|
Login in to Rate this Post:
0
?
|
|
let me google that for youhttp://unixwiz.net/tools/whoamip.html is this what you had in mind? some codes here: http://forums.debian.net/viewtopic.php?t=31673&sid=77365c8c16168343211ec674e17826cc
|
|
|
i_my
Please log in to subscribe to i_my's postings.
Posted on 12-01-08 11:38
PM
Reply
[Subscribe]
|
Login in to Rate this Post:
0
?
|
|
|
|
|
techGuy
Please log in to subscribe to techGuy's postings.
Posted on 12-01-08 11:50
PM
Reply
[Subscribe]
|
Login in to Rate this Post:
0
?
|
|
wow sedif..didnt know abt let me google that for you, that was nice
http://tinyurl.com/6p2z7d (This just for test)
Dont know much abt C, but got following from http://www.cygwin.com/ml/cygwin/2004-04/msg00894.html, might be of some help.
/* little utility to get the IP address of the machine
- prints the IP address in triple-dotted form xxx.yyy.zzz.www,
or nothing if can't get it.
- this code is a fragment from EpidEm code.
*/
#include <stdio.h>
#include <arpa/inet.h>
#include <netinet/in.h>
#include <unistd.h>
#include <netdb.h>
/*
Returns the IP address of this host.
- if host have more than 1 IP, only 1 (the first) is returned.
- return is in network byte order
- thanks to Doct. Ghini (www.cs.unibo.it/~ghini)
return: 0 if unsuccessful, the IP otherwise
*/
in_addr_t get_my_IP()
{
/* have you ever seen a hostname longer than a screen (80cols)?*/
char name[80]; /*store my hostname*/
struct hostent * hostent_ptr;
int ret;
ret = gethostname (name, 80);
if(ret == -1) {
/*printf ("ERROR gethostname() failed, Errno=%d \nDescription: %s\n", errno,
strerror(errno));*/
return 0;
}
hostent_ptr = gethostbyname(name);
if(hostent_ptr == NULL)
{
/*printf ("ERROR gethostbyname() failed, h_errno=%d \nDescription: %s\n", h_errno, hstrerror(h_errno));*/
return 0;
}
/*h_addr_list contains IPs of this host in network byte order */
return ((struct in_addr *)hostent_ptr->h_addr_list[0])->s_addr; /*get the first IP.*/
}
int main()
{
in_addr_t my_ip = get_my_IP();
if (my_ip != 0)
{
struct in_addr temp;
temp.s_addr = my_ip;
printf("%s\n", inet_ntoa(temp));
}
return 0;
}
|
|
|
sedif
Please log in to subscribe to sedif's postings.
Posted on 12-02-08 12:28
AM
Reply
[Subscribe]
|
Login in to Rate this Post:
0
?
|
|
np @techGuy: ya read a Digg post on it, cleaver idea.
|
|
|
Sleepless
Please log in to subscribe to Sleepless's postings.
Posted on 12-02-08 7:49
AM
Reply
[Subscribe]
|
Login in to Rate this Post:
0
?
|
|
Yes , gethostbyname( ) does it.
But werent you looking for Client's IP Address? And if you are coding for a Proxy Server, and all you can do is code in that server? I'd suggest you use connection request headers from the clients to find its IP Address.
|
|
|
sajhakhohero
Please log in to subscribe to sajhakhohero's postings.
Posted on 12-02-08 7:46
PM
Reply
[Subscribe]
|
Login in to Rate this Post:
0
?
|
|
Can someone know how to crack these array problems please.
1. Write a program to double the array elements with odd indices?
Eg. Element 1, 2,3,4,5,6,7,8
Soln: 1,6,10,14 <program only double the element with odd indices>
2. Find the first element larger than 100.
thank you
|
|
|
Sakura_Blossom
Please log in to subscribe to Sakura_Blossom's postings.
Posted on 12-03-08 1:56
AM
Reply
[Subscribe]
|
Login in to Rate this Post:
0
?
|
|
|
|