/* 
 * File:   EtherServer.h
 * Author: Joe Churchwell
 *
 * Created on February 26, 2013, 2:43 PM
 */

#ifndef SERVER_H
#define	SERVER_H

#ifdef	__cplusplus
extern "C" {
#endif
    
#ifdef	__cplusplus
}
#endif

#include "epackage.h"

class EtherServer {
    
   // PRIVATE VARIABLE DECLARATIONS...
    sockaddr_in clientAddress;
    int sockfd; // Socket File Descriptor
	
	//The highest version of Windows Sockets specification that the caller can use. 
	//The high-order byte specifies the minor version number                                                          
	WORD version;    

	//Structure Contains information about the Windows Sockets implementation.
	WSADATA wsaData;
	
   // DEFINE PRIVATE FUNCTIONS HERE...
        // Function to close the file descriptor
        void CloseFileDescriptor();

public:
        // Constructor
	EtherServer();
        
        // Destructor
        ~EtherServer();
	
        // Get the client information
        struct sockaddr_in GetClientInformation();
	
        // Open up an Ethernet Port
		unsigned int OpenEthernetPort(unsigned int port_number);
        
        // Write an array of bytes to the Ethernet interface
        int Write(const char *charArray, unsigned int length);
        
        // This function will read data from the Ethernet 
        // port and will not wait (block)
        int Retrieve(char *msg, unsigned int * size); 
        
        // Read data bytes from the Ethernet interface and 
        // block until bytes are read
        int RetrieveWait(char *msg, signed int * size);        

};

#endif	/* SERVER_H */

