Tao.Sdl SDK Documentation

SdlNet.SDLNet_AllocPacketV Method 

Allocate a vector of UDPpackets

[Visual Basic]
Public Shared Function SDLNet_AllocPacketV( _
   ByVal howmany As Integer, _
   ByVal size As Integer _
) As IntPtr
[C#]
public static IntPtr SDLNet_AllocPacketV(
   int howmany,
   int size
);

Parameters

howmany
The number of UDPpackets to allocate.
size
Size, in bytes, of the data buffers to be allocated in the new UDPpackets. Zero is invalid.

Return Value

a pointer to a new empty UDPpacket vector. NULL is returned on errors, such as out-of-memory.

Remarks

Create (via malloc) a vector of new UDPpackets, each with data buffers of size bytes. The new packet vector should be freed using SDLNet_FreePacketV when you are done using it. The returned vector is one entry longer than requested, for a terminating NULL.

Binds to C-function call in SDL_net.h:

            extern DECLSPEC UDPpacket ** SDLCALL SDLNet_AllocPacketV(int howmany, int size)
            

Example

            // create a new UDPpacket vector to hold 1024 bytes of data in 10 packets
            UDPpacket **packetV;
            packetV=SDLNet_AllocPacketV(10, 1024);
            if(!packetV) {
            printf("SDLNet_AllocPacketV: %s\n", SDLNet_GetError());
            // perhaps do something else since you can't make this packet
            }
            else {
            // do stuff with this new packet vector
            // SDLNet_FreePacketV this packet vector when finished with it
            }
            

See Also

SdlNet Class | Tao.Sdl Namespace | SdlNet.UDPpacket | SdlNet.IPaddress | SDLNet_AllocPacketV | SDLNet_ResizePacket | SDLNet_FreePacket | SDLNet_UDP_Send | SDLNet_UDP_SendV