mirror of
https://github.com/alliedmodders/amxmodx.git
synced 2024-12-25 14:25:38 +03:00
1fb91dc02e
Conflicts: plugins/include/amxmodx.inc plugins/include/message_const.inc plugins/include/sockets.inc
71 lines
1.9 KiB
PHP
Executable File
71 lines
1.9 KiB
PHP
Executable File
// vim: set ts=4 sw=4 tw=99 noet:
|
|
//
|
|
// AMX Mod X, based on AMX Mod by Aleksander Naszko ("OLO").
|
|
// Copyright (C) The AMX Mod X Development Team.
|
|
//
|
|
// Codebase from Ivan, -g-s-ivan@web.de (AMX 0.9.3)
|
|
// Modification by Olaf Reusch, kenterfie@hlsw.de (AMXX 0.16, AMX 0.96)
|
|
//
|
|
// This software is licensed under the GNU General Public License, version 3 or higher.
|
|
// Additional exceptions apply. For full license details, see LICENSE.txt or visit:
|
|
// https://alliedmods.net/amxmodx-license
|
|
|
|
//
|
|
// Socket Functions
|
|
//
|
|
|
|
#if defined _socket_included
|
|
#endinput
|
|
#endif
|
|
#define _socket_included
|
|
|
|
#if AMXX_VERSION_NUM >= 175
|
|
#pragma reqlib sockets
|
|
#if !defined AMXMODX_NOAUTOLOAD
|
|
#pragma loadlib sockets
|
|
#endif
|
|
#else
|
|
#pragma library socket
|
|
#endif
|
|
|
|
// 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(const _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, const _data[], _length);
|
|
|
|
/* Same as socket_send but Data can contain null bytes */
|
|
|
|
native socket_send2(_socket, const _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);
|