/*  xSockets
 *
 *  Created by Boylett
 *  Copyright (c) Xendot
 *
 */

#if defined _xsockets_included
	#endinput
#endif
#define _xsockets_included
#pragma library xsockets

/*
	Macros
*/

#define RECV_ERROR Recv:-1
#define SOCKET_ERROR Socket:-1

/*
	Natives
*/

native Socket:socket_tcp_create(host[],port);
native bool:socket_tcp_write(Socket:socket_id,buf[]);
native Recv:socket_tcp_read(Socket:socket_id,buflen);
native bool:socket_tcp_receive_newline(Socket:socket_id);

native Socket:socket_udp_create();
native bool:socket_udp_write(Socket:socket_id,buf[],host[],port);
native Recv:socket_udp_receive_newline_any(Socket:socket_id);
native Recv:socket_udp_receive_newline(Socket:socket_id,host[],port);
native Recv:socket_udp_read_any(Socket:socket_id,buflen);
native Recv:socket_udp_read(Socket:socket_id,buflen,host[],port);

native bool:socket_close(Socket:socket_id);

/*
	Callbacks
*/

forward OnSocketClose(Socket:socket_id);
forward OnTCPSocketReceiveNewline(Socket:socket_id,buf[],Recv:recvid);
forward OnTCPSocketReceive(Socket:socket_id,buf[],Recv:recvid);
forward OnUDPSocketReceiveNewline(Socket:socket_id,buf[],Recv:recvid);
forward OnUDPSocketReceive(Socket:socket_id,buf[],Recv:recvid);
