Академический Документы
Профессиональный Документы
Культура Документы
Script Arguments:
port : Port to host the server socket on. Stored in the
NetTcp_Prt globalvar.
maxclients : Total number of clients that can connect to the
server.
buffer size : Size to use when creating the fixed sized buffer.
Script Note:
This script uses dynamic memory, make sure to delete the
memory via
Net_TcpDestory() when the sockets are no longer
needed.
The Net_TcpServer(), Net_TcpClient() and Net_TcpClientRaw()
scripts all
store their socket IDs and buffer IDs inside of the
NetTcp_Sck and NetTcp_Bfr
globalvars. So attempting to call
these scripts one after the other in one
project will result
in each socket and buffer being over written by the next
call of
the scripts. This will result in losing socket IDs and buffer IDs and will
result in a memory leak. To avoid this, call Net_TcpDestroy()
before calling
the next script.
Script Return Value:
1 if the server socket was successfully created, -1 if the server
socket failed to
be created.
NetUdp_Cast(). This
NetUdp_Map globalvar.
Script Arguments:
port : Port to host the UDP sever on. Stored in the NetUdp_Prt
globalvar.
maxclients : UDP servers do not support client connections, set
to 0.
url / ip : The URL or IPv4 address to host the server on. Stored
in the
NetUdp_Ipa globalvar.
buffer size : Size to use when creating the fixed sized buffer.
Script Notes:
This script uses dynamic memory, make sure to delete the
memory via
Net_UdpDestory() when the sockets are no longer
needed.
Script Return Value:
1 if the client and server sockets were successfully created, -1 if
the client and
server sockets failed to be created.
socket
Net_Bytes( buffer id );
Net_Bytes() returns the total number of bytes written to the buffer from
the current seek position of the buffer. This script is a simple rename and
pass through for GameMaker: Studio's buffer_tell( buffer id ) function.
Script Return Value:
The script returns a default value of 0.
Net_Analyze( packet id );
Net_Analyze() checks the current connection of a client to a server to
see if the connection is still valid.
Script Return Value:
1 if the connection is still valid and -1 if the conneciton has been
lost.
Net_Inquire( buffer id );
Net_Inquire() this script is a followup script to Net_UdpCast(). If a
-- Socket Requesting Scripts -Socket requesting is a system where the server sends each client a packet,
telling the client to request it's socket ID from the server as a form of
identification.
Net_Enqueue( packet id ); (1. Used on Server)
Loops through all of the non-requested sockets in the NetTcp_Que
ds_list on the server and sends a verification packet to each socket. This
packet when received by the client with Net_Requeue() tells the client to
finalize requesting it's socket.
Script Return Value:
The script returns a default value of 0.
Net_TcpAssets( asset id );
Net_TcpAssets() returns the value of the specified asset via asset id.
List of Assets: (asset IDs -> defined constants)
tcp_asset_sck(NetTcp_Sck) : Server / Client socket ID.
tcp_asset_bfr(NetTcp_Bfr) : Server / Client buffer ID.
tcp_asset_con(NetTcp_Con) : Last client socket ID to connect to the
server.
tcp_asset_dis(NetTcp_Dis) : Last client socket ID to disconnect from
the server.
tcp_asset_ipa(NetTcp_Ipa) : IP address the client(raw client) socket is
connected to.
tcp_asset_prt(NetTcp_Prt) : Port the client(raw client) socket is
connected on.
tcp_asset_lst(NetTcp_Lst) : (Server) List ID of client sockets connected
to the server.
tcp_asset_que(NetTcp_Que) : (Server) List ID of unrequested client
socket IDs.
tcp_asset_lsz(size of NetTcp_Lst) : (Server) Size of list in asset
tcp_asset_lst.
tcp_asset_qsz(size of NetTcp_Que) : (Server) Size of list in asset
tcp_asset_que.
Net_UdpAssets( asset id );
Net_UdpAssets() returns the value of the specified asset via asset id.
List of Assets: (asset IDs -> defined constants)
udp_asset_sck(NetUdp_Sck) : UDP "client" socket.
udp_asset_hst(NetUdp_Hst) : UDP "server" socket.
udp_asset_bfr(NetUdp_Bfr) : Server buffer ID.
udp_asset_ipa(NetUdp_Ipa) : URL / IP the server is hosted on.
udp_asset_prt(NetUdp_Prt) : Port the server is hosted on.
udp_asset_map(NetUdp_Map) : ds_map of servers foudn with
broadcasting.
udp_asset_msx(size of NetUdp_Map) : Size of list in asset
udp_asset_map.
Extra Constants:
network_error(-1) : used for checking if a socket has an error.
network_noerror(1) : used for checking if a socket has no error.