openTRI 0.1
triNet.h
1/*
2 * triNet.h: Header for wifi
3 * This file is part of the "tri Engine".
4 *
5 * Copyright (C) 2007 tri
6 * Copyright (C) 2007 InsertWittyName <tias_dp@hotmail.com>
7 *
8 * $Id: $
9 *
10 * This program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published by
12 * the Free Software Foundation; either version 2 of the License, or
13 * (at your option) any later version.
14 *
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
19 *
20 * You should have received a copy of the GNU General Public License
21 * along with this program; if not, write to the Free Software
22 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
23 */
24
25#ifndef __TRINET_H__
26#define __TRINET_H__
27
28#include <psputility.h>
29#include <netinet/in.h>
30
31#include "triTypes.h"
32
36
37#define TRI_SOCKET_TCP SOCK_STREAM
38#define TRI_SOCKET_UDP SOCK_DGRAM
39
40#define TRI_LOCAL_IP 0
41#define TRI_REAL_IP 1
42
43#define TRI_MAX_CLIENTS 256
44
48typedef struct
49{
50 triUInt index;
51 netData name;
53
57typedef int triSocket;
58
62typedef fd_set triSocketSet;
63
71triBool triNetInit();
72
82triUInt triNetGetConfigs(triNetConfig *configs, triUInt count);
83
90
98triBool triNetConnect(triNetConfig *config);
99
104
111
117triBool triNetGetLocalIp(char *buffer);
118
126triChar* triNetResolveHost(triChar *hostname);
127
134
143
153triBool triNetSocketBind(triSocket socket, triU16 port);
154
164triBool triNetSocketListen(triSocket socket, triUInt maxConnections);
165
173triBool triNetSocketConnect(triSocket socket, char *ip, triU16 port);
174
184triSInt triNetSocketSend(triSocket socket, const char *data, triSInt length);
185
195triSInt triNetSocketReceive(triSocket socket, char *data);
196
203
210
219
228
239
247triSInt triNetSocketSelect(triUInt maxSockets, triSocketSet *set);
248
258triVoid triNetGetUrl(triChar *url, triChar *response);
259
261
262#endif // __TRINET_H__
triSocket triNetSocketCreate(void)
Create a socket.
triVoid triNetDisconnect()
Disconnect from an access point.
triVoid triNetSocketSetClear(triSocketSet *set)
Clear a socket set.
triVoid triNetGetUrl(triChar *url, triChar *response)
Save web 'item' (page/file etc)
triBool triNetInit()
Initialise the wifi.
triSInt triNetSocketReceive(triSocket socket, char *data)
Receive data using a socket.
triSocket triNetSocketAccept(triSocket socket)
Accept a new connection.
triChar * triNetResolveHost(triChar *hostname)
Resolve a host name to an IP.
triVoid triNetSocketClose(triSocket socket)
Close a socket.
triBool triNetConnect(triNetConfig *config)
Connect to an access point.
int triSocket
A socket.
Definition triNet.h:57
triSInt triNetSocketSelect(triUInt maxSockets, triSocketSet *set)
Remove a socket from a socket set.
fd_set triSocketSet
A socket set (group)
Definition triNet.h:62
triVoid triNetSocketSetRemove(triSocket socket, triSocketSet *set)
Remove a socket from a socket set.
triBool triNetSocketConnect(triSocket socket, char *ip, triU16 port)
Connect using a socket.
triBool triNetGetLocalIp(char *buffer)
Get local IP.
triVoid triNetSocketSetAdd(triSocket socket, triSocketSet *set)
Add a socket to a socket set.
triBool triNetIsConnected()
Check connected to an access point.
triBool triNetSocketSetIsMember(triSocket socket, triSocketSet *set)
Check for socket updates within a set.
triBool triNetSocketListen(triSocket socket, triUInt maxConnections)
Listen on a socket for incoming connections.
triSInt triNetSocketSend(triSocket socket, const char *data, triSInt length)
Send data using a socket.
triBool triNetSwitchStatus()
Get the status of the wlan switch.
triUInt triNetGetConfigs(triNetConfig *configs, triUInt count)
Get the connection configs.
triBool triNetSocketBind(triSocket socket, triU16 port)
Bind a socket to an address/port.
Connection config.
Definition triNet.h:49
triUInt index
Connection index.
Definition triNet.h:50
netData name
Connection name.
Definition triNet.h:51