getting the IP address sent



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,sizeof(one))==-1)
{
//perror("bootpc: setsockopt failed");
//FatalError();
}
from.sin_addr.s_addr =inet_addr(255.255.255.255);

.



Relevant Pages

  • Re: What doesnt lend itself to OO?
    ... >> proxy and instructs the server to constuct the real object. ... rather than client code. ... If 'clock' is instantiated in the server, ... > for the server interface at the OOA level. ...
    (comp.object)
  • This is going straight to the pool room
    ... or not the client has privilege to do what they're trying to do, ... The server environment is this: ... 3GL User action Routines that Tier3 will execute on your behalf during the ... Routine Name: USER_INIT ...
    (comp.os.vms)
  • [Full-Disclosure] R: Full-Disclosure Digest, Vol 3, Issue 42
    ... Full-Disclosure Digest, Vol 3, Issue 42 ... SD Server 4.0.70 Directory Traversal Bug ... Arkeia Network Backup Client Remote Access ...
    (Full-Disclosure)
  • Re: What doesnt lend itself to OO?
    ... > rather than client code. ... no way to do that without also touching the object with clock semantics ... will not encapsulate both clock semantics and network semantics. ... The server can do whatever it wants ...
    (comp.object)
  • RE: Fax monitor incoming + outgoing calls?
    ... problem between the client computer and the SBS server. ... Client is using the internal IP address of the SBS server as the ... To the folder redirection GPO issue: ...
    (microsoft.public.windows.server.sbs)