reSIProcate/stack  9694
Functions
testSource.cxx File Reference
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <stdlib.h>
#include <string.h>
#include <arpa/inet.h>
#include <iostream>
#include "rutil/Data.hxx"
#include "rutil/DnsUtil.hxx"
#include "rutil/Tuple.hxx"
Include dependency graph for testSource.cxx:

Go to the source code of this file.

Functions

int main (int argc, char *argv[])

Function Documentation

int main ( int  argc,
char *  argv[] 
)

Definition at line 17 of file testSource.cxx.

References resip::DnsUtil::inet_ntop(), and len.

{

   int sockfd;
   char buffer[1024];

   socklen_t len;
   struct sockaddr_in cliaddr, servaddr;

   if (argc != 2)
   {
      exit(0);
   }
   using namespace resip;

   sockfd = socket(AF_INET, SOCK_DGRAM, 0);

   memset(&servaddr, 0, sizeof(servaddr));
   servaddr.sin_family = AF_INET;
   const int serv_port = 9999;
   servaddr.sin_port = htons(9999);

   inet_pton(AF_INET, argv[1], &servaddr.sin_addr);
   inet_ntop(AF_INET, &servaddr.sin_addr, buffer,1024);
   
   std::cout << "Sending to : " << buffer << std::endl;
   
   connect(sockfd, (const sockaddr*)&servaddr, sizeof(servaddr));

   len = sizeof(cliaddr);
   getsockname(sockfd, (sockaddr*)&cliaddr, &len);
   inet_ntop(AF_INET, &cliaddr.sin_addr, buffer, 1024);
   std::cout << "new local source is: " << buffer << std::endl;
   std::cout << "DnsUtil::inet_ntop = " 
             << DnsUtil::inet_ntop(cliaddr.sin_addr)
             << std::endl;


   return 0;
}

Here is the call graph for this function: