Logo
~Sockets~
~Examples~
~Contact~


UdpTestSocket Class Reference

#include <UdpTestSocket.h>

List of all members.


Public Member Functions

 UdpTestSocket (ISocketHandler &)
void OnRawData (const char *, size_t, struct sockaddr *, socklen_t)

Detailed Description

Definition at line 7 of file UdpTestSocket.h.


Constructor & Destructor Documentation

UdpTestSocket::UdpTestSocket ( ISocketHandler &   ) 

Definition at line 5 of file UdpTestSocket.cpp.

00006 :UdpSocket(h)
00007 {
00008 }


Member Function Documentation

void UdpTestSocket::OnRawData ( const char *  ,
size_t  ,
struct sockaddr *  ,
socklen_t   
)

Definition at line 11 of file UdpTestSocket.cpp.

00012 {
00013         if (sa_len == sizeof(struct sockaddr_in)) // IPv4
00014         {
00015                 struct sockaddr_in sa;
00016                 memcpy(&sa,sa_from,sa_len);
00017                 ipaddr_t a;
00018                 memcpy(&a,&sa.sin_addr,4);
00019                 std::string ip;
00020                 Utility::l2ip(a,ip);
00021                 printf("Received %d bytes from: %s:%d\n", l,ip.c_str(),ntohs(sa.sin_port));
00022                 printf("%s\n",static_cast<std::string>(p).substr(0,l).c_str());
00023         }
00024 #ifdef ENABLE_IPV6
00025 #ifdef IPPROTO_IPV6
00026         else
00027         if (sa_len == sizeof(struct sockaddr_in6)) // IPv6
00028         {
00029                 struct sockaddr_in6 sa;
00030                 memcpy(&sa,sa_from,sa_len);
00031                 std::string ip;
00032                 Utility::l2ip(sa.sin6_addr,ip);
00033                 printf("(IPv6) Received %d bytes from: %s:%d\n", l,ip.c_str(),ntohs(sa.sin6_port));
00034                 printf("%s\n",static_cast<std::string>(p).substr(0,l).c_str());
00035         }
00036 #endif
00037 #endif
00038 }


The documentation for this class was generated from the following files:
Page, code, and content Copyright (C) 2006 by Anders Hedström
Generated on Mon Aug 29 20:21:47 2005 for C++ Sockets by  doxygen 1.4.4