CSFML 3.0.0
Loading...
Searching...
No Matches
UdpSocket.h
Go to the documentation of this file.
1
2//
3// SFML - Simple and Fast Multimedia Library
4// Copyright (C) 2007-2024 Laurent Gomila (laurent@sfml-dev.org)
5//
6// This software is provided 'as-is', without any express or implied warranty.
7// In no event will the authors be held liable for any damages arising from the use of this software.
8//
9// Permission is granted to anyone to use this software for any purpose,
10// including commercial applications, and to alter it and redistribute it freely,
11// subject to the following restrictions:
12//
13// 1. The origin of this software must not be misrepresented;
14// you must not claim that you wrote the original software.
15// If you use this software in a product, an acknowledgment
16// in the product documentation would be appreciated but is not required.
17//
18// 2. Altered source versions must be plainly marked as such,
19// and must not be misrepresented as being the original software.
20//
21// 3. This notice may not be removed or altered from any source distribution.
22//
24
25#pragma once
26
28// Headers
30#include <CSFML/Network/Export.h>
31
32#include <CSFML/Network/IpAddress.h>
33#include <CSFML/Network/SocketStatus.h>
34#include <CSFML/Network/Types.h>
35
36#include <stddef.h>
37
38
45 CSFML_NETWORK_API sfUdpSocket* sfUdpSocket_create(void);
46
53 CSFML_NETWORK_API void sfUdpSocket_destroy(const sfUdpSocket* socket);
54
71 CSFML_NETWORK_API void sfUdpSocket_setBlocking(sfUdpSocket* socket, bool blocking);
72
81 CSFML_NETWORK_API bool sfUdpSocket_isBlocking(const sfUdpSocket* socket);
82
94 CSFML_NETWORK_API unsigned short sfUdpSocket_getLocalPort(const sfUdpSocket* socket);
95
118 CSFML_NETWORK_API sfSocketStatus sfUdpSocket_bind(sfUdpSocket* socket, unsigned short port, sfIpAddress address);
119
130 CSFML_NETWORK_API void sfUdpSocket_unbind(sfUdpSocket* socket);
131
148 CSFML_NETWORK_API sfSocketStatus
149 sfUdpSocket_send(sfUdpSocket* socket, const void* data, size_t size, sfIpAddress remoteAddress, unsigned short remotePort);
150
171 CSFML_NETWORK_API sfSocketStatus sfUdpSocket_receive(
172 sfUdpSocket* socket,
173 void* data,
174 size_t size,
175 size_t* received,
176 sfIpAddress* remoteAddress,
177 unsigned short* remotePort);
178
194 CSFML_NETWORK_API sfSocketStatus
195 sfUdpSocket_sendPacket(sfUdpSocket* socket, sfPacket* packet, sfIpAddress remoteAddress, unsigned short remotePort);
196
211 CSFML_NETWORK_API sfSocketStatus
212 sfUdpSocket_receivePacket(sfUdpSocket* socket, sfPacket* packet, sfIpAddress* remoteAddress, unsigned short* remotePort);
213
221 CSFML_NETWORK_API unsigned int sfUdpSocket_maxDatagramSize(void);
222
230 CSFML_NETWORK_API unsigned short sfUdpSocket_anyPort(void);
IpAddress.h
Export.h
CSFML_NETWORK_API
#define CSFML_NETWORK_API
Definition Network/Export.h:42
Types.h
sfPacket
struct sfPacket sfPacket
Definition Network/Types.h:35
sfUdpSocket
struct sfUdpSocket sfUdpSocket
Definition Network/Types.h:39
SocketStatus.h
sfSocketStatus
sfSocketStatus
Define the status that can be returned by the socket functions.
Definition SocketStatus.h:32
sfUdpSocket_receive
sfSocketStatus sfUdpSocket_receive(sfUdpSocket *socket, void *data, size_t size, size_t *received, sfIpAddress *remoteAddress, unsigned short *remotePort)
Receive raw data from a remote peer with a UDP socket.
sfUdpSocket_getLocalPort
unsigned short sfUdpSocket_getLocalPort(const sfUdpSocket *socket)
Get the port to which a UDP socket is bound locally.
sfUdpSocket_destroy
void sfUdpSocket_destroy(const sfUdpSocket *socket)
Destroy a UDP socket.
sfUdpSocket_bind
sfSocketStatus sfUdpSocket_bind(sfUdpSocket *socket, unsigned short port, sfIpAddress address)
Bind a UDP socket to a specific port.
sfUdpSocket_isBlocking
bool sfUdpSocket_isBlocking(const sfUdpSocket *socket)
Tell whether a UDP socket is in blocking or non-blocking mode.
sfUdpSocket_setBlocking
void sfUdpSocket_setBlocking(sfUdpSocket *socket, bool blocking)
Set the blocking state of a UDP listener.
sfUdpSocket_receivePacket
sfSocketStatus sfUdpSocket_receivePacket(sfUdpSocket *socket, sfPacket *packet, sfIpAddress *remoteAddress, unsigned short *remotePort)
Receive a formatted packet of data from a remote peer with a UDP socket.
sfUdpSocket_anyPort
unsigned short sfUdpSocket_anyPort(void)
Return the special value that tells the system to pick any available port.
sfUdpSocket_unbind
void sfUdpSocket_unbind(sfUdpSocket *socket)
Unbind a UDP socket from the local port to which it is bound.
sfUdpSocket_send
sfSocketStatus sfUdpSocket_send(sfUdpSocket *socket, const void *data, size_t size, sfIpAddress remoteAddress, unsigned short remotePort)
Send raw data to a remote peer with a UDP socket.
sfUdpSocket_create
sfUdpSocket * sfUdpSocket_create(void)
Create a new UDP socket.
sfUdpSocket_sendPacket
sfSocketStatus sfUdpSocket_sendPacket(sfUdpSocket *socket, sfPacket *packet, sfIpAddress remoteAddress, unsigned short remotePort)
Send a formatted packet of data to a remote peer with a UDP socket.
sfUdpSocket_maxDatagramSize
unsigned int sfUdpSocket_maxDatagramSize(void)
Return the maximum number of bytes that can be sent in a single UDP datagram.
sfIpAddress
Encapsulate an IPv4 network address.
Definition IpAddress.h:40