1/* (c) Magnus Auvinen. See licence.txt in the root of the distribution for more information. */
2/* If you are missing that file, acquire a complete release at teeworlds.com. */
3#include <base/system.h>
4
5enum
6{
7 NUM_SOCKETS = 64
8};
9
10void Run(NETADDR Dest)
11{
12 NETSOCKET aSockets[NUM_SOCKETS];
13
14 for(auto &Socket : aSockets)
15 {
16 NETADDR BindAddr = {.type: NETTYPE_IPV4, .ip: {0}, .port: 0};
17 Socket = net_udp_create(bindaddr: BindAddr);
18 }
19
20 while(true)
21 {
22 unsigned char aData[1024];
23 int Size = 0;
24 int SocketToUse = 0;
25 io_read(io: io_stdin(), buffer: &Size, size: 2);
26 io_read(io: io_stdin(), buffer: &SocketToUse, size: 1);
27 Size %= 256;
28 SocketToUse %= NUM_SOCKETS;
29 io_read(io: io_stdin(), buffer: aData, size: Size);
30 net_udp_send(sock: aSockets[SocketToUse], addr: &Dest, data: aData, size: Size);
31 }
32}
33
34int main(int argc, const char **argv)
35{
36 CCmdlineFix CmdlineFix(&argc, &argv);
37 NETADDR Dest = {.type: NETTYPE_IPV4, .ip: {127, 0, 0, 1}, .port: 8303};
38 Run(Dest);
39 return 0;
40}
41