Blamite Game Engine - blam!  00296.01.12.21.0102.blamite
The core library for the Blamite Game Engine.
socket.h
Go to the documentation of this file.
1 #pragma once
2 
3 #include <winsock.h>
4 
5 #include "messages.h"
6 
7 #ifndef BLAM
8 #define BLAM
9 #endif
10 
11 namespace Blam
12 {
13  struct Endpoint
14  {
15  UINT32 address;
16  UINT16 port;
17  };
18 
19  struct Socket
20  {
21  SOCKET handle;
22  };
23 
25  {
26  UINT8* memory;
27  UINT8* next;
29  };
30 
31  BLAM void linearAllocCreate(Blam::LinearAllocator* alloc, UINT64 size);
32  BLAM UINT8* linearAlloc(Blam::LinearAllocator* alloc, UINT64 size);
33 
34  namespace Network
35  {
36  struct PacketBuffer
37  {
38  UINT32 index;
39  UINT32 size;
40  UINT8* packets;
41  UINT32* packetSizes;
43  LARGE_INTEGER* times;
44  };
45 
46  struct Socket
47  {
51  bool receive;
52  };
53 
54  BLAM bool Init();
56  BLAM void Close(Socket* socket);
57  BLAM bool Bind(Socket* socket, Endpoint* endpoint);
58  BLAM bool Send(Socket* socket, UINT8* packet, UINT32 packetSize, Endpoint* endpoint);
59  BLAM bool Receive(Socket* socket, UINT8* buffer, UINT32 bufferSize, UINT32* packetSizeOut, Endpoint* endpoint);
60 
61  BLAM bool IsConnected();
62 
63  BLAM void HandleReceive(Socket* sock, UINT8* socketBuffer, UINT32 bufferSize, UINT32* outPacketSize, Endpoint* outFrom);
64  }
65 }
Blam
Namespace surrounding all major engine components.
Definition: blam_api.h:18
Blam::Network::Receive
BLAM bool Receive(Socket *socket, UINT8 *buffer, UINT32 bufferSize, UINT32 *packetSizeOut, Endpoint *endpoint)
Definition: socket.cpp:324
Blam::Socket
Definition: socket.h:19
Blam::Endpoint::port
UINT16 port
Definition: socket.h:16
Blam::Network::Init
BLAM bool Init()
Definition: socket.cpp:248
Blam::LinearAllocator::next
UINT8 * next
Definition: socket.h:27
Blam::Network::PacketBuffer::endpoints
Endpoint * endpoints
Definition: socket.h:42
Blam::Network::PacketBuffer::packets
UINT8 * packets
Definition: socket.h:40
Blam::LinearAllocator::bytesRemaining
UINT64 bytesRemaining
Definition: socket.h:28
Blam::Network::Socket::recvBuf
PacketBuffer recvBuf
Definition: socket.h:50
Blam::Socket::handle
SOCKET handle
Definition: socket.h:21
Blam::Network::Socket
Definition: socket.h:46
socketBuffer
UINT8 * socketBuffer
– TO BE FILLED IN BY VERTIGO –
Definition: main.cpp:70
Blam::Network::PacketBuffer::packetSizes
UINT32 * packetSizes
Definition: socket.h:41
Blam::linearAllocCreate
BLAM void linearAllocCreate(Blam::LinearAllocator *alloc, UINT64 size)
Definition: socket.cpp:157
Blam::Network::PacketBuffer::times
LARGE_INTEGER * times
Definition: socket.h:43
Blam::Network::Bind
BLAM bool Bind(Socket *socket, Endpoint *endpoint)
Definition: socket.cpp:292
allocator
Blam::LinearAllocator allocator
– TO BE FILLED IN BY VERTIGO –
Definition: main.cpp:72
Blam::Network::IsConnected
BLAM bool IsConnected()
Definition: socket.cpp:380
Internal::socket
bool socket(Blam::Socket *outSocket)
Definition: socket.cpp:52
messages.h
Blam::Network::Send
BLAM bool Send(Socket *socket, UINT8 *packet, UINT32 packetSize, Endpoint *endpoint)
Definition: socket.cpp:304
Blam::Network::Socket::sock
Blam::Socket sock
Definition: socket.h:48
Blam::Network::Start
BLAM bool Start(Socket *socket, LinearAllocator *allocator)
Definition: socket.cpp:263
Blam::linearAlloc
BLAM UINT8 * linearAlloc(Blam::LinearAllocator *alloc, UINT64 size)
Definition: socket.cpp:164
sock
Blam::Network::Socket sock
– TO BE FILLED IN BY VERTIGO –
Definition: main.cpp:71
Blam::Network::PacketBuffer
Definition: socket.h:36
Blam::LinearAllocator::memory
UINT8 * memory
Definition: socket.h:26
Blam::Network::HandleReceive
BLAM void HandleReceive(Socket *sock, UINT8 *socketBuffer, UINT32 bufferSize, UINT32 *outPacketSize, Endpoint *outFrom)
Definition: socket.cpp:364
BLAM
#define BLAM
Definition: discord_rpc.h:8
Blam::Network::Close
BLAM void Close(Socket *socket)
Definition: socket.cpp:278
Blam::Network::Socket::receive
bool receive
Definition: socket.h:51
Blam::Network::Socket::sendBuf
PacketBuffer sendBuf
Definition: socket.h:49
Blam::Endpoint::address
UINT32 address
Definition: socket.h:15
Blam::LinearAllocator
Definition: socket.h:24
Blam::Endpoint
Definition: socket.h:13
Blam::Network::PacketBuffer::size
UINT32 size
Definition: socket.h:39
Blam::Network::PacketBuffer::index
UINT32 index
Definition: socket.h:38