x


How to detect if X ip is a client or a server

Hey, i realise there are the functions. Network.Isclient and Network.IsServer, however they dont match my needs. Im trying to compare an IP address with the servers IP address, if(Network.player.ipAddress != TheOtherIpaddress) doesnt work as when the server uses this function, the var TheOtherIpaddress, is empty, but doesnt register as null.

Not sure if this is making half the sense it should.

Note, The server works as a server/client system, its not standalone.

more ▼

asked Dec 14 '09 at 06:23 PM

Scoots gravatar image

Scoots
12 2 2 3

Could you provide some more information on the setup and perhaps a code snippet illustrating the context of your problem?

Dec 14 '09 at 10:43 PM AngryAnt ♦♦
(comments are locked)
10|3000 characters needed characters left

2 answers: sort voted first

I think you just need to create an RPC function in a persistent gameobject in your scene (the one called connectionGUI in the official multiplayer project). That rpc function needs to "return" the IP, so quite simply at a point (possibly OnNetworkLevelLoad or a similar one-shot system function) you make a call.

networkView.RPC("getserveripaddressfunction",RPCMode.Server);

In the same script there's the following

string serveripaddress = ""; //this will hold the server ip address after the call

[RPC] //this will -only- be called against the server
void getserveripaddressfunction(NetworkMessageInfo info) {
  networkView.RPC("sendbackserveripaddress", info.sender, Network.player.ipAddress);
}

      //the client will receive this call asynchronously, after the server receives
[RPC] //the request with the above function
void sendbackserveripaddress(string serveripaddressparam) {
  serveripaddress = serveripaddressparam;
}

so that your "serveripaddress" variable is conveniently loaded once you need it, after 'OnNetworkLevelLoad' has executed.

Welcome to the horrible world of networking

more ▼

answered Aug 05 '11 at 10:48 AM

roamcel gravatar image

roamcel
1.2k 37 40 44

(comments are locked)
10|3000 characters needed characters left

IP monitor helps you to detect the IP address. It monitors your network devices, servers, and applications.

more ▼

answered Aug 17 '10 at 05:12 AM

user-4182 (yahoo) gravatar image

user-4182 (yahoo)
1

(comments are locked)
10|3000 characters needed characters left
Your answer
toggle preview:

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Topics:

x697
x413

asked: Dec 14 '09 at 06:23 PM

Seen: 1437 times

Last Updated: Aug 05 '11 at 10:50 AM