2013-07-12 21:30:13 +02:00
|
|
|
/*****************************************************************************
|
|
|
|
* Socket.h *
|
|
|
|
* *
|
|
|
|
* System::Net::Socket class definition file *
|
|
|
|
* Based on Windows Phone Socket class. *
|
|
|
|
* Copyright (c) XFX Team. All Rights Reserved *
|
|
|
|
*****************************************************************************/
|
2013-05-05 18:18:41 +02:00
|
|
|
#ifndef _SYSTEM_NET_SOCKET_
|
|
|
|
#define _SYSTEM_NET_SOCKET_
|
|
|
|
|
|
|
|
#include "Enums.h"
|
|
|
|
#include "../EndPoint.h"
|
|
|
|
#include <System/Interfaces.h>
|
|
|
|
#include <System/Object.h>
|
|
|
|
|
|
|
|
#include <xboxkrnl/xboxkrnl.h>
|
|
|
|
|
|
|
|
using namespace System;
|
|
|
|
|
|
|
|
namespace System
|
|
|
|
{
|
|
|
|
namespace Net
|
|
|
|
{
|
|
|
|
namespace Sockets
|
|
|
|
{
|
|
|
|
class SocketAsyncEventArgs;
|
|
|
|
|
2013-07-12 21:30:13 +02:00
|
|
|
class Socket : public IDisposable, public Object
|
2013-05-05 18:18:41 +02:00
|
|
|
{
|
|
|
|
private:
|
|
|
|
AddressFamily_t addressFamily;
|
2014-07-22 17:02:45 +02:00
|
|
|
/* true if we called Close_internal */
|
|
|
|
bool closed;
|
2013-05-05 18:18:41 +02:00
|
|
|
HANDLE handle;
|
2013-10-03 17:38:47 +02:00
|
|
|
bool isConnected;
|
|
|
|
ProtocolType_t protocolType;
|
2013-05-05 18:18:41 +02:00
|
|
|
|
|
|
|
protected:
|
|
|
|
void Dispose(bool disposing);
|
|
|
|
|
|
|
|
public:
|
2014-07-14 15:03:46 +02:00
|
|
|
AddressFamily_t getAddressFamily() const;
|
|
|
|
int Available() const;
|
|
|
|
bool Connected() const;
|
|
|
|
HANDLE getHandle() const;
|
2014-07-22 17:02:45 +02:00
|
|
|
static bool OSSupportsIPv4();
|
2014-07-14 15:03:46 +02:00
|
|
|
ProtocolType_t getProtocolType() const;
|
2013-05-05 18:18:41 +02:00
|
|
|
int ReceiveBufferSize;
|
2014-07-14 15:03:46 +02:00
|
|
|
EndPoint* getRemoteEndPoint() const;
|
2013-05-05 18:18:41 +02:00
|
|
|
int SendBufferSize;
|
|
|
|
short Ttl;
|
|
|
|
|
|
|
|
Socket(AddressFamily_t addressFamily, SocketType_t socketType, ProtocolType_t protocolType);
|
2014-07-22 17:02:45 +02:00
|
|
|
virtual ~Socket();
|
2013-05-05 18:18:41 +02:00
|
|
|
|
2014-07-22 17:02:45 +02:00
|
|
|
static void CancelConnectAsync(SocketAsyncEventArgs * const e);
|
2013-05-05 18:18:41 +02:00
|
|
|
void Close();
|
|
|
|
void Close(int timeOut);
|
|
|
|
static bool ConnectAsync(SocketType_t socketType, ProtocolType_t protocolType, SocketAsyncEventArgs e);
|
2014-07-22 17:02:45 +02:00
|
|
|
bool ConnectAsync(SocketAsyncEventArgs * const e);
|
2013-05-05 18:18:41 +02:00
|
|
|
void Dispose();
|
2013-07-12 21:30:13 +02:00
|
|
|
void EndConnect(IAsyncResult * asyncResult);
|
|
|
|
void EndDisconnect(IAsyncResult * asyncResult);
|
|
|
|
static const Type& GetType();
|
2014-07-22 17:02:45 +02:00
|
|
|
bool ReceiveAsync(SocketAsyncEventArgs * const e);
|
|
|
|
bool ReceiveFromAsync(SocketAsyncEventArgs * const e);
|
|
|
|
bool SendAsync(SocketAsyncEventArgs * const e);
|
|
|
|
bool SendToAsync(SocketAsyncEventArgs * const e);
|
2013-05-05 18:18:41 +02:00
|
|
|
void Shutdown(SocketShutdown_t how);
|
|
|
|
};
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif //_SYSTEM_NET_SOCKET_
|