TobiiGlasses2SDK
Public Member Functions
Network Class Reference

#include <Network.h>

List of all members.

Public Member Functions

 Network ()
int makeSocket ()
int bindSocket (struct sockaddr_in &dest, int sock)
void configureSockAddr (struct sockaddr_in &sockaddr, const char *inetaddr, int port)
int sendUDPTo (struct sockaddr_in &sockaddr, int sockfd, const char *msg)
int recvUDPFrom (struct sockaddr_in *sockaddr, int sockfd, std::string &msgout, bool dontwait=false)
void clearSocket (int sock)
void printErrors ()

Detailed Description

This class is a UDP Network wrapper for low level C functions.


Constructor & Destructor Documentation

This constructor will setup the Network API for windows

Author:
Pierre-Marie Plans

Member Function Documentation

int Network::bindSocket ( struct sockaddr_in &  dest,
int  sock 
)

Bind a destination address to a socket

Author:
Pierre-Marie Plans
Parameters:
in(int) socket file descriptor
inout(struct sockaddr_in) address
Returns:
1 if success, 0 else
void Network::clearSocket ( int  sock)

Closes the socket.

Author:
Pierre-Marie Plans
Parameters:
in(int) socket file descriptor
void Network::configureSockAddr ( struct sockaddr_in &  sockaddr,
const char *  inetaddr,
int  port 
)

Init a sockaddress with the values provided.

Author:
Pierre-Marie Plans
Parameters:
inout(struct sockaddr_in) address
in(const char *) address to bind, NULL is considered as Broadcast address
in(int) port
Returns:
1 if success, 0 else

Make a DGRAM socket and returns the socket file descriptor

Author:
Pierre-Marie Plans
Returns:
socket file descriptor (int)

Will print network API errors on STDERR standard output.

Author:
Pierre-Marie Plans
int Network::recvUDPFrom ( struct sockaddr_in *  sockaddr,
int  sockfd,
std::string &  msgout,
bool  dontwait = false 
)

Receive an UDP packet from a given address. For the moment it reads only 1024 bytes.

Author:
Pierre-Marie Plans
Parameters:
in(struct sockaddr_in) address
in(int) socket file descriptor
out(std::string) packet received
Returns:
number of bytes read, 0 or less means an error occured.
int Network::sendUDPTo ( struct sockaddr_in &  sockaddr,
int  sockfd,
const char *  msg 
)

Send a UDP packet to a specific address.

Author:
Pierre-Marie Plans
Parameters:
in(struct sockaddr_in) address
in(int) socket file descriptor
in(const char *) packet to send, finishing by '\0' char
Returns:
1 if success, 0 else

The documentation for this class was generated from the following files:
 All Classes Namespaces Files Functions Variables