[SOLVED] Both client and server from one application


photo

Recommended Posts

Hi,

 

Is there a way in Unigine to allow one application to run multiple servers or a server and a client simultaneously? I have tried these :

 

1. network.startServer( "", 50000, MAX_CLIENTS );

    network.startServer( "",  50001, MAX_CLIENTS );

 

2. network.startServer( "", 50000, MAX_CLIENTS ); 

    NetworkAddress serverAddress = network.getMyAddress();

    network.connectToServer( serverAddress );

 

In both cases the second attempt (the blue line) throws an error saying 'this network node is already connected' or something along that line. Am I missing something basic? Thanks.

Link to post

Hello, Santosh.

 

It's a restrictions of the old network plugin. Consider using Sockets (https://developer.unigine.com/en/docs/1.0/scripting/core/class.socket) If you're not relying on stuff such as NAT punch-through and high-level architecture of a plugin.

 

This is the only way you're able to run two servers or server & client simultaneously in one unigine app. Please look at samples/systems/socket_xx samples.

Link to post

Thanks Unclebob. No I won't be needing NAT punch-through so I think I'm better off using sockets.

Link to post

You're welcome, Santosh!

 

Don't hesitate to ask more. :)

Link to post

Today I was going through other forum threads on networking and I happened upon this one - https://developer.unigine.com/forum/topic/503-socket-handling/. It suggests that socket programming is not the best way for game networking. Our networking need is quite similiar to game networking in complexity, maybe little more. So that means I cannot rely on socket programming.

 

Our network will include at least 10-12 units, each with 3-6 sub-units. Thats why we prefer a distributed networking model with multiple levels of client-server relationship. This was the reason for my primary query since some network nodes are clients as well as server to other clients. What would you suggest to me in such a situation?

Link to post

Santosh,

 

Thanks for clarifying your use case. Could you please give me a little bit more details about your setup? Why do you need some of your network nodes be both clients and servers? Will these nodes transmit data to their clients? If so, what will be after they'll receive another data from different server?

 

I'd say that feature you need is peer-to-peer networking. Network plugin was designed to have strict client-server structure so I can suggest a few things:

 

1) The best option is to go and modify plugin source code and remove that "only client or server" restriction. If you have binary or source license then plugin source code should be inside source/plugins/Network/RakNet folder. I also dig into RakNet forums and it seems that they have peer-to-peer sample so I think it's possible to implement that feature;

 

2) Try to use socket programming to do peer-to-peer stuff on top of network plugin;

 

3) (Not a good idea but still may work) Try to add specific packet type which will be handled only by specific client so the server (I assume we have strict client-server structure with dedicated server) will act as a transfer point.

Link to post
Thanks Unclebob! I have drawn a quick and ugly sketch of what we require. The grey boxes represent self-contained simulation units. A here is the main view (of a car or any vehicle), 1/2/3 etc are sub-views. Firstly A+1+2+3, B+4+5+6, etc. are self-contained units. A can be converted to dedicated sever, if need be.

 

We can let A be the server to which all other units & subunits act as clients. But 1) we want to retain the networking of the self-contained units 2) we do no want all other units be clients to A, we want to distribute the traffic by making sub-units transfer data with B, C and D. Note that B (like C and D) is client to A but servers to 4, 5 and 6. Hope I explained it clearly.

 

1. Unfortunately we do not have source license.

 

2. I can do the B->4/5/6 level networking using sockets but am apprehensive of it as there's lot of data passing every tick.

 

3. I'm sorry I missed your point there.

post-1093-0-90554200-1421040562_thumb.png

Link to post

Am I understand you correctly that all you need to do is to have classic client-server architecture between, uhm, let's call them 'vehicles' or 'units' (big circles in your graph) and be able to have different machines as a 'views' (small circles) of single 'unit'?

 

If so, then you can use network plugin for 'units' with no restrictions and use syncker and CIGI or Unigine::Syncker to sync between actual 'unit' and its 'view'. That's actually what HAL network protocol does but we don't have support for it unfortunately.

 

More about Unigine::Syncker here: https://developer.unigine.com/en/docs/1.0/scripting/scripts/systems/unigine_syncker/

CIGI sample here: https://developer.unigine.com/en/docs/1.0/scripting/samples/plugins/cigi_client_00

 

P.S. Don't worry about "passing a lot of data through the sockets" because every network stuff does that (even RakNet in our network plugin).

P.P.S. You don't have to have source license, because network plugin source code is included in binary license as well.

Link to post
  • 1 month later...

Just realised that I forgot replying back to this post :) Thanks unclebob for all the help.

Link to post