NET Incoming Accept

From Bennu Wiki
Jump to navigation Jump to search


Up to Network.DLL Functions



Definition

INT NET_Incoming_Accept ( <WORD listen_connection> )

On the specified listening connection, accepts the last incoming connection. When the NET.Incoming[listen_connection] value becomes NET_STATUS_ESTABLISHED, this function can be used to accept the connection and retrieve the connectionID of the new incoming connection.

For a function that waits for a new connection, see NET_Accept().

Parameters

WORD listen_connection - The connection identifier of the listening connection on which a new incoming connection is made.

Returns

INT : Network.DLL Errorcode

NET_ERROR_INVALIDCONN - The connection is invalid.
NET_ERROR_CONNINACTIVE - The connection is inactive.
NET_ERROR_TOOFEWCONNS - There are no new incoming connections on the specified listening connection.
0 - n - Connection identifier of the incoming connection on the specified listening connection. (Where n is the number of maximum allowed connections)

Example

As an example, here is the code for NET_Accept():

Function int NET_Accept(word listen_conn);
Begin

/* Checks */

	if(listen_conn>=NET.maxlistenports)
		if(NET.consolereports)
			NET_ConsoleMessage(listen_conn,"Error: Connection " + listen_conn + " invalid");
		end
		return NET_ERROR_INVALIDCONN;
	end
	if(NET.Status[listen_conn]<=NET_STATUS_INACTIVE)
		if(NET.consolereports)
			NET_ConsoleMessage(listen_conn,"Error: Connection " + listen_conn + " not active");
		end
		return NET_ERROR_CONNINACTIVE;
	end

/* Wait for new connection */

	While(NET.Incoming[listen_conn]!=NET_STATUS_ESTABLISHED)
		frame;
	End
	listen_conn = net_incoming_accept(listen_conn);

	return listen_conn;

End

Used in example: NET.Incoming, NET_Incoming_Accept()


Network.DLL Functions
Global NET_Init() • NET_Quit() • NET_Version() • NET_IntVersion() • NET_About() • NET_GetError() • NET_Stat_Buffer() • NET_IntToIP() • NET_IPToInt()
Connections NET_Connect() • NET_Listen() • NET_Disconnect() • NET_DisconnectAll() • NET_Accept() • NET_Incoming_Accept()
Connection NET_Resolve() • NET_Hostname() • NET_IPAddress() • NET_Port() • NET_Separator() • NET_GetSeparator() • NET_GetSeparatorLength()
Transfer NET_Recv() • NET_RecvFile() • NET_RecvGraph() • NET_RecvVar() • NET_Send() • NET_SendFile() • NET_SendGraph() • NET_SendRN() • NET_SendVar()