AGSsock plugin brings Network Sockets for Adventure Game Studio.
The API is how you will interact with AGSsock plugin through AGS Script.
static SockData* SockData.Create(int size, char defchar = 0)
Creates a new data container with specified size (and what character to fill it with)
static SockData* SockData.CreateEmpty()
Creates a new data container of zero size
static SockData* SockData.CreateFromString(const string str)
Creates a data container from a string.
attribute int Size
attribute char Chars[]
String SockData.AsString()
Makes and returns a string from the data object.
Warning: anything after a null character will be truncated.
void SockData.Clear()
Removes all the data from a socket data object, reducing its size to zero.
static SockAddr* SockAddr.Create(int type = IPv4)
Creates an empty socket address. (advanced: set type to IPv6 if you're using IPv6)
static SockAddr* SockAddr.CreateFromString(const string address, int type = IPv4)
Creates a socket address from a string. (for example: "http://www.adventuregamestudio.co.uk\")
static SockAddr* SockAddr.CreateFromData(SockData *)
Creates a socket address from raw data. (advanced)
static SockAddr* SockAddr.CreateIP(const string address, int port)
Creates a socket address from an IP-address. (for example: "127.0.0.1
")
static SockAddr* SockAddr.CreateIPv6(const string address, int port)
Creates a socket address from an IPv6-address. (for example: "::1
")
attribute int SockAddr.Port
attribute String SockAddr.Address
attribute String SockAddr.IP
SockData* SockAddr.GetData()
Returns a SockData object that contains the raw data of the socket address. (advanced)
static Socket* Socket.Create(int domain, int type, int protocol = 0)
Creates a socket for the specified protocol. (advanced)
static Socket* Socket.CreateUDP()
Creates a UDP socket. (unreliable, connectionless, message based)
static Socket* Socket.CreateTCP()
Creates a TCP socket. (reliable, connection based, streaming)
static Socket* Socket.CreateUDPv6()
Creates a UDP socket for IPv6. (when in doubt use CreateUDP)
static Socket* Socket.CreateTCPv6()
Creates a TCP socket for IPv6. (when in doubt use CreateTCP)
static int Socket.LastError
attribute String Tag
readonly attribute SockAddr *Local
readonly attribute SockAddr *Remote
readonly attribute bool Valid
SockError Socket.ErrorValue()
Returns the last error observed from this socket as an enumerated value.
String Socket.ErrorString()
Returns the last error observed from this socket as an human readable string.
bool Socket.Bind(SockAddr *local)
Binds the socket to a local address. (generally used before listening)
bool Listen(int backlog = 10)
Makes a socket listen for incoming connection requests. (TCP only) Backlog specifies how many requests can be queued. (optional)
bool Socket.Connect(SockAddr *host, bool async = false)
Makes a socket connect to a remote host. (for UDP it will simply bind to a remote address) Defaults to sync which makes it wait; see the manual for async use.
Socket* Socket.Accept()
Accepts a connection request and returns the resulting socket when successful. (TCP only)
void Socket.Close()
Closes the socket. (you can still receive until socket is marked invalid)
bool Socket.Send(const string msg)
Sends a string to the remote host. Returns whether successful. (no error means: try again later)
bool Socket.SendTo(SockAddr *target, const string msg)
Sends a string to the specified remote host. (UDP only)
String Socket.Recv()
Receives a string from the remote host. (no error means: try again later)
String Socket.RecvFrom(SockAddr *source)
Receives a string from an unspecified host. The given address object will contain the remote address. (UDP only)
bool Socket.SendData(SockData *data)
Sends raw data to the remote host. Returns whether successful. (no error means: try again later)
bool Socket.SendDataTo(SockAddr *target, SockData *data)
Sends raw data to the specified remote host. (UDP only)
SockData *Socket.RecvData()
Receives raw data from the remote host. (no error means: try again later)
SockData* Socket.RecvDataFrom(SockAddr *source)
Receives raw data from an unspecified host. The given address object will contain the remote address. (UDP only)
This plugin was created by Ferry "Wyz" Timmers, and it's license is provided in LICENSE.txt
.