2014-02-20 11:01:25 +01:00
|
|
|
#ifndef NETWORK_DEPENDENCIES_CONNECTIONUDP_H
|
|
|
|
#define NETWORK_DEPENDENCIES_CONNECTIONUDP_H
|
|
|
|
|
|
|
|
//////////////////////////////////
|
|
|
|
// Created by Sam Svensson 2013 //
|
|
|
|
//////////////////////////////////
|
|
|
|
|
|
|
|
#include "IConnection.h"
|
|
|
|
#include "../NetworkDependencies/OysterByte.h"
|
|
|
|
|
|
|
|
namespace Oyster
|
|
|
|
{
|
|
|
|
namespace Network
|
|
|
|
{
|
|
|
|
class ConnectionUDP : public IConnection
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
ConnectionUDP();
|
|
|
|
ConnectionUDP( int socket);
|
|
|
|
virtual ~ConnectionUDP();
|
|
|
|
|
|
|
|
virtual int InitiateServer( unsigned short port );
|
|
|
|
virtual int InitiateClient();
|
|
|
|
|
2014-02-23 18:38:20 +01:00
|
|
|
virtual int InitiateBroadcastServer(unsigned short port, const char serverName[]);
|
|
|
|
virtual int InitiateBroadcastClient(unsigned short port);
|
2014-02-20 11:01:25 +01:00
|
|
|
|
|
|
|
virtual int Send ( OysterByte &byte );
|
|
|
|
virtual int Recieve( OysterByte &byte );
|
|
|
|
|
|
|
|
virtual int Connect( unsigned short port, const char serverName[] );
|
|
|
|
|
2014-02-23 18:38:20 +01:00
|
|
|
//Doesn't do anything now.
|
|
|
|
virtual int Reconnect() { return 0; }
|
|
|
|
|
2014-02-20 11:01:25 +01:00
|
|
|
virtual int Disconnect();
|
|
|
|
|
|
|
|
bool IsSending();
|
|
|
|
bool IsConnected();
|
|
|
|
int GetIpSize();
|
|
|
|
|
|
|
|
int SetBlockingMode( bool blocking );
|
|
|
|
|
|
|
|
private:
|
|
|
|
int InitiateSocket();
|
|
|
|
|
|
|
|
int socket;
|
|
|
|
//char ipAddress[16];
|
|
|
|
//unsigned short port;
|
|
|
|
int ipSize;
|
|
|
|
|
|
|
|
unsigned long Address;
|
|
|
|
unsigned short port;
|
|
|
|
|
|
|
|
bool stillSending;
|
|
|
|
bool closed;
|
|
|
|
};
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|