Network API
#71
What did the server log say about creating a second socket?
Reply
Thanks given by:
#72
It did say that he created one, but I just can't reach it.
Reply
Thanks given by:
#73
Well, duh, there was code missing for the second socket Smile
I installed WinXP mode on my Win7 laptop and tried it out, it now seems to work.
Reply
Thanks given by:
#74
That explains it Smile

So should I test it once again(tomorrow), or are we done testing for now? Wink

I tried it, and it works normaly for me on Windows XP
Reply
Thanks given by:
#75
Great. So we have a working base for the API; if @worktycho doesn't have more comments about the code, we can start actually moving the server internals to use this.
Reply
Thanks given by: NiLSPACE
#76
I don't have any other issues with the code. I think we should start moving over as soon as possible.
Reply
Thanks given by:
#77
I'd like to change the connection-accepting code, so that the link callbacks that are given to the new link are received from the cNetwork::cListenCallbacks::OnAccepted() callback, rather than given to the cNetwork::Listen() function. Without this, it would become too cumbersome to actually use the cNetwork API in the server (binding the connections to clients would require several helper classes).

Unfortunately this means that the OnAccepted() callback will not be able to receive a cTCPLink instance, because the instance needs those callbacks to be created. If this proves to be a problem, we can add a second callback, OnLinkCreated() that will be called right after the link is created for the new connection.
Or maybe keep the OnAccept() callback as is, but add an OnIncomingConnection() callback that is called first to obtain the link callbacks:
class cNetwork
{
	...
	class cListenCallbacks
	{
	public:
		/** Called when the TCP server created with Listen() receives a new incoming connection.
		Returns the link callbacks that the server should use for the newly created link.
		If a nullptr is returned, the connection is dropped immediately;
		otherwise a new cTCPLink instance is created and OnAccepted() is called. */
		virtual cTCPLink::cCallbacksPtr OnIncomingConnection(const AString & a_RemoteIPAddress) = 0;

		/** Called when the TCP server created with Listen() creates a new link for an incoming connection.
		Provides the newly created Link that can be used for communication.
		Called right after a successful OnIncomingConnection(). */
		virtual void OnAccepted(cTCPLink & a_Link) = 0;

		...
Reply
Thanks given by:
#78
I guess no comment means no-one's against this, so I'll do it.
Reply
Thanks given by:
#79
Exacly Smile
Reply
Thanks given by:
#80
If we're having an network API for lua, then it might be usefull for plugins to be able to compress/decompress strings. Maybe we can create a zlib API?
Reply
Thanks given by:




Users browsing this thread: 5 Guest(s)