/* Socket functions
 *
 * (c) Copyright 2006, Ivan, -g-s-ivan@web.de
 * This file is provided as is (no warranties).
 * 
 * IMPORTANT NOTICE: USE ON YOUR OWN RISK ONLY, MODULE MAY CRASH YOUR HLDS OR EVEN MORE!
 * The module give you nearly unfiltered access to your OS' Socket API, which means also
 * that you could easily crash your Server.
 * You shouldn't develop Plugins with this Module IF you CANNOT easily restart your HLDS!
 */

#if defined _socket_included
	#endinput
#endif
#define _socket_included

// Use SOCKET_TCP for TCP Socket connections

#define SOCKET_TCP 1

// Use SOCKET_UDP for UDP Socket connections

#define SOCKET_UDP 2

/* Opens a new connection to hostname:port via protocol (either SOCKET_TCP or SOCKET_UDP),
 * returns a socket (positive) or negative or zero on error.
 * States of error:
 * 0 - no error
 * 1 - error while creating socket
 * 2 - couldn't resolve hostname
 * 3 - couldn't connect to given hostname:port 
*/

native socket_open(_hostname[], _port, _protocol = SOCKET_TCP, &_error);

/* Closes a Socket */

native socket_close(_socket);

/* Recieves Data to string with the given length */

native socket_recv(_socket, _data[], _length);

/* Sends data to the Socket */

native socket_send(_socket, _data[], _length);

/* This function will return true if the state (buffer content) have changed within the last recieve or
* the timeout, where timeout is a value in µSeconds, (1 sec =1000000 µsec). 
* Use to check if new data is in your socket. */

native socket_change(_socket, _timeout=100000);

