Echo Server based on the legacy EthernetNetIf libraries used for a performance comparison with the new networking libraries

Dependencies:   EthernetNetIf mbed

Fork of EchoServer by ryosuke kojima

EchoServer.h

Committer:
emilmont
Date:
2012-08-01
Revision:
1:7b4661a721c1
Parent:
0:fcd581e3ad7d

File content as of revision 1:7b4661a721c1:

#ifndef ECHO_SERVER_H
#define ECHO_SERVER_H

#include "mbed.h"
#include "TCPSocket.h"
#include "UDPSocket.h"
#include "EthernetNetIf.h"

#include "TCPEchoHandler.h"
#include <netservice.h>
/*
    Class: EchoServer
    Binds itself to port 7 on TCP and UDP and listens for
    incoming connections
*/
class EchoServer {
public:
    // Constructor: EchoServer
    // Creates the TCP and UDP sockets and wires up
    // the event callback methods
    EchoServer();
    // Destructor: ~EchoServer
    // Deletes the TCP and UDP sockets
    ~EchoServer();
    /*
        Function: bind
        Binds the sockets to the specified ports
        Parameters:
            tcpPort - The TCP port to bind to (default 7 as per RFC862)
            udpPort - The UDP port to bind to (default 7 as per RFC862)
     */
    void bind(int tcpPort=7, int udpPort=7);
private:
    // Variable: tcpSock
    // The TCP server socket
    TCPSocket* tcpSock;
    // Variable: udpSock
    // The UDP socket
    UDPSocket* udpSock;
    
    // Function: onNetTcpSocketEvent
    // The callback function called by the network stack whenever an
    // event occurs on the TCP socket
    // Parameter: e - The event that has occurred
    void onNetTcpSocketEvent(TCPSocketEvent e);
    // Function: onNetUdpSocketEvent
    // The callback function called by the network stack whenever an
    // event occurs on the UDP socket
    // Parameter: e - The event that has occurred
    void onNetUdpSocketEvent(UDPSocketEvent e);
};

#endif