Whisper Library
 All Classes Functions Variables Typedefs Enumerations Friends
whisper_library::SocketSender Class Reference

Sends packets over a raw Socket. More...

Public Member Functions

void sendTcp (string source_ip, string destination_ip, TcpPacket packet)
 sends a tcp packet to destination ip address More...
 
void sendUdp (string destination_ip, UdpPacket packet)
 sends a udp packet to destination ip address More...
 

Private Member Functions

std::string packetToString (vector< bool > packetData)
 converts packet data to string More...
 
ulong ipToUlong (string ip)
 converts a ip from string to ulong representation More...
 

Detailed Description

Sends packets over a raw Socket.

This class can be used to send packets to a destination ip address. It uses raw sockets to do so. On unix tcp and udp packets can be send, on windows, since XP SP3, the use of raw sockets is restricted, only udp packets can be send.

Member Function Documentation

ulong whisper_library::SocketSender::ipToUlong ( string  ip)
private

converts a ip from string to ulong representation

Parameters
ipthe IPv4 as text
Returns
the IPv4 as ulong
std::string whisper_library::SocketSender::packetToString ( vector< bool >  packetData)
private

converts packet data to string

The packet data gets converted from vector<bool> to std::string, so it can be processed easily.

Parameters
packetDatathe data to convert
Returns
a text representation of the data
void whisper_library::SocketSender::sendTcp ( string  source_ip,
string  destination_ip,
TcpPacket  packet 
)

sends a tcp packet to destination ip address

The checksum for the packet is calculated based on the given ip addresses and than the packet is send over a raw socket.

Parameters
source_ipthe senders ip address
destination_ipthe receivers ip address
packetthe packet that gets send
void whisper_library::SocketSender::sendUdp ( string  destination_ip,
UdpPacket  packet 
)

sends a udp packet to destination ip address

Parameters
destination_ipthe receivers ip address
packetthe packet that gets send