2011-03-17 16:38:30 +00:00
|
|
|
/* (c) Magnus Auvinen. See licence.txt in the root of the distribution for more information. */
|
|
|
|
/* If you are missing that file, acquire a complete release at teeworlds.com. */
|
|
|
|
#include <base/system.h>
|
|
|
|
|
2020-09-26 19:41:58 +00:00
|
|
|
enum
|
|
|
|
{
|
|
|
|
NUM_SOCKETS = 64
|
|
|
|
};
|
2011-03-17 16:38:30 +00:00
|
|
|
|
2011-04-02 20:49:16 +00:00
|
|
|
void Run(NETADDR Dest)
|
2011-03-17 16:38:30 +00:00
|
|
|
{
|
|
|
|
NETSOCKET aSockets[NUM_SOCKETS];
|
2011-04-13 18:37:12 +00:00
|
|
|
|
2020-10-26 14:14:07 +00:00
|
|
|
for(auto &Socket : aSockets)
|
2011-03-17 16:38:30 +00:00
|
|
|
{
|
|
|
|
NETADDR BindAddr = {NETTYPE_IPV4, {0}, 0};
|
2020-10-26 14:14:07 +00:00
|
|
|
Socket = net_udp_create(BindAddr);
|
2011-03-17 16:38:30 +00:00
|
|
|
}
|
2011-04-13 18:37:12 +00:00
|
|
|
|
2022-02-14 23:12:52 +00:00
|
|
|
while(true)
|
2011-03-17 16:38:30 +00:00
|
|
|
{
|
|
|
|
unsigned char aData[1024];
|
|
|
|
int Size = 0;
|
|
|
|
int SocketToUse = 0;
|
|
|
|
io_read(io_stdin(), &Size, 2);
|
|
|
|
io_read(io_stdin(), &SocketToUse, 1);
|
|
|
|
Size %= 256;
|
|
|
|
SocketToUse %= NUM_SOCKETS;
|
|
|
|
io_read(io_stdin(), aData, Size);
|
|
|
|
net_udp_send(aSockets[SocketToUse], &Dest, aData, Size);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-11-21 17:16:14 +00:00
|
|
|
int main(int argc, const char **argv)
|
2011-03-17 16:38:30 +00:00
|
|
|
{
|
2021-11-21 17:16:14 +00:00
|
|
|
cmdline_fix(&argc, &argv);
|
2020-09-26 19:41:58 +00:00
|
|
|
NETADDR Dest = {NETTYPE_IPV4, {127, 0, 0, 1}, 8303};
|
2011-03-17 16:38:30 +00:00
|
|
|
Run(Dest);
|
2021-11-21 17:16:14 +00:00
|
|
|
cmdline_free(argc, argv);
|
2011-03-17 16:38:30 +00:00
|
|
|
return 0;
|
|
|
|
}
|