Networking Forums

Networking Forums > Computer Networking > Linux Networking > getting the IP address sent

Reply
Thread Tools Display Modes

getting the IP address sent

 
 
mohun106@gmail.com
Guest
Posts: n/a

 
      04-26-2006, 09:04 AM
Hi,

I have a server running on one linux system. The client sends UDP
packets. It has two options---one is send broadcast address and other
is send the address of the server system if known.

How to detect at the server side that what address is sent by the
client?

My server program is below:

if((sfd=socket(AF_INET,SOCK_DGRAM,0))<0)
errexit("cant open stream\n");

memset(&srvadr,0,sizeof(srvadr));
srvadr.sin_family =AF_INET;
//srvadr.sin_addr.s_addr =inet_addr(srvipadrs);
srvadr.sin_addr.s_addr =inet_addr(255.255.255.255);
srvadr.sin_port =htons(srvtcpport);


if(bind(sfd,(struct sockaddr*)&srvadr , sizeof(srvadr)) < 0)
errexit("Can't bind local address\n");
printf("Socket is Opened Waiting for reply\n");
memset(&rxmesg,0,sizeof(rxmesg));
fromlen=sizeof(from);

if(recvfrom(sfd,rxmesg,7,0,(struct sockaddr*)&from,&fromlen)<0)
errexit("recv error \n");
//printf("Received Message is %s\n",rxmesg);
printf(" Received Message from %s:%d\n",
inet_ntoa(from.sin_addr),ntohs(from.sin_port));

if (setsockopt(sfd,SOL_SOCKET,SO_BROADCAST,&one,sizeo f(one))==-1)
{
//perror("bootpc: setsockopt failed");
//FatalError();
}
from.sin_addr.s_addr =inet_addr(255.255.255.255);

 
Reply With Quote
 
 
 
Reply

Thread Tools
Display Modes

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 On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Pipex Address: Post Office wont sent registered letter as they say the address is invalid! W Broadband 16 05-13-2008 09:30 PM
Coffee shop wifi will not give me IP address, but gives everyone else IP address. But static IP works! Jennifer R Wireless Internet 5 09-30-2007 06:12 AM
access violation at address 004075e5 module WUSB54G4.exe of address 00000368 Houndog Wireless Internet 10 02-13-2006 06:56 PM
"access violation at address 004075e5 module WUSB54G4.exe of address 00000368 Houndog Windows Networking 0 02-12-2006 09:40 PM
When Linux PC boots, Does it sends RARP packet to get its IP address by embedding its Hardware address? santa19992000@yahoo.com Linux Networking 2 10-16-2005 10:40 PM



1 2 3 4 5 6 7 8 9 10 11