[Half-Life AMXX] / include / sockets.inc Repository:
ViewVC logotype

Annotation of /include/sockets.inc

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1 - (view) (download)

1 : ian 1 /*
2 :     *
3 :     * AMX Mod X Module
4 :     * Basic Socket Functions
5 :     *
6 :     * Codebase from Ivan, -g-s-ivan@web.de (AMX 0.9.3)
7 :     * Modification by Olaf Reusch, kenterfie@hlsw.de (AMXX 0.16, AMX 0.96)
8 :     *
9 :     */
10 :    
11 :     #if defined _socket_included
12 :     #endinput
13 :     #endif
14 :     #define _socket_included
15 :    
16 :     #if AMXX_VERSION_NUM >= 175
17 :     #pragma reqlib sockets
18 :     #if !defined AMXMODX_NOAUTOLOAD
19 :     #pragma loadlib sockets
20 :     #endif
21 :     #else
22 :     #pragma library socket
23 :     #endif
24 :    
25 :     // Use SOCKET_TCP for TCP Socket connections
26 :    
27 :     #define SOCKET_TCP 1
28 :    
29 :     // Use SOCKET_UDP for UDP Socket connections
30 :    
31 :     #define SOCKET_UDP 2
32 :    
33 :     /* Opens a new connection to hostname:port via protocol (either SOCKET_TCP or SOCKET_UDP),
34 :     * returns a socket (positive) or negative or zero on error.
35 :     * States of error:
36 :     * 0 - no error
37 :     * 1 - error while creating socket
38 :     * 2 - couldn't resolve hostname
39 :     * 3 - couldn't connect to given hostname:port
40 :     */
41 :    
42 :     native socket_open(const _hostname[], _port, _protocol = SOCKET_TCP, &_error);
43 :    
44 :     /* Closes a Socket */
45 :    
46 :     native socket_close(_socket);
47 :    
48 :     /* Recieves Data to string with the given length */
49 :    
50 :     native socket_recv(_socket, _data[], _length);
51 :    
52 :     /* Sends data to the Socket */
53 :    
54 :     native socket_send(_socket, const _data[], _length);
55 :    
56 :     /* Same as socket_send but Data can contain null bytes */
57 :    
58 :     native socket_send2(_socket, const _data[], _length);
59 :    
60 :     /* This function will return true if the state (buffer content) have changed within the last recieve or
61 :     * the timeout, where timeout is a value in µSeconds, (1 sec =1000000 µsec).
62 :     * Use to check if new data is in your socket. */
63 :    
64 :     native socket_change(_socket, _timeout=100000);

Contact
ViewVC Help
Powered by ViewVC 1.0.4