Basic Networking Issues - Guidance Required
Hi, I have been trying to simple networking in which i can send a message from one device to another. My first thoughts were 'Would I have to pay to use unity multiplayer functionality?' so I found this [article][1] which seemed clear and directly explained how I would need to do networking in order to maintain zero costs on my behalf. After further searching I discovered [this][2] bit of unity documentation which seems to explain how to do networking simply in the same way described in the previous article and eluded to simple message sending which I desired.
But I have seemed to ground to a halt in this journey of discovery as I have found no further articles or videos to guide me and answer my questions which i still have about how this works.
Hence today i am asking :
A - Do you know of any further articles or videos which would guide me through this?
B - Am i going totally in the wrong direction?
C - Could you answer any of my key questions as below?
When creating a server, i.e below, what port should i listen on and should I worry about 'port forwarding' which is a phrase I see often chucked about.
NetworkServer.Listen(4444);
When creating a client, i.e below, what i.p address should i use? I presume it is that of the client's device but how do i know what it is?
myClient.Connect("127.0.0.1", 4444);
How do i get 2 devices to connect, my idea was to make any device by default become a client and then somehow 'check for servers' and if not it would create its own server with local client for a client to connect to, this way there would be no excess servers... ?
Thanks you very much for reading my question and I hope it seems clear, please check the links so that this will make sense to you. Any answers are greatly appreciated so that i can continue on my journey of understanding.
[1]: http://stackoverflow.com/questions/36091976/can-i-use-the-unity-networking-hlapi-without-paying-for-the-unity-multiplayer-se/36092168 [2]: https://docs.unity3d.com/Manual/UNetClientServer.html
If you require any more detail or there is anything i can do just say
you kinda have to have a server to make game copies talk. when most machines log onto a router they can be given a different local IP address everytime. (this is called a dynamic IP) so the problem is finding where they are at. the difference with a server is it always stays at the same address and port so people can always find it (this is called a static IP). if you want to learn about networking you should start by setting your pc to a static IP. its as simple as changing a setting in your computer to ask for the same local ip address everytime. then logging into your router and picking a port that is forwarded to your computer. you can google a youtube video and do it in twenty $$anonymous$$utes.
anyways, a lot of game servers only job it to keep track of all the players and there current addresses and then hand out that info so players can directly connect to each other.
I just use port 23466 think its unity's default. you can use any port around there and it will work as long as the server is set to listen to the same port as the client is trying to connect too! there are some port numbers that popular programs use that you want to avoid. you can find the lists on google. but 23466 and 23467 isnt used by anything big.
unitys source code for there basic server is free to anyone. you can down load it off there website. or you can just find a copy of the build. if your on a static ip you simply just click on it and it works. if you need to know what IP you clients need to connect to, just type "what is my IP" into google on your server machine and it will tell you your public IP that your internet provider gave you.
I hope this answers some questions for you!
Thanks @toddisarockstar, having been down the route of using this version of networking I found I lacked knowledge and was getting into many complex question so i decided to use photon networking which has free elements but in the long term i may look back into this when (if) my user total grows photon will become costly. Thank you very much for your reply it may serve me well in the future, sorry for my late reply.
Answer by g__l · Aug 04, 2016 at 02:01 PM
An answer by the person who made the stack overflow article i linked can be found here - http://stackoverflow.com/questions/38673176/unity-client-server-basic-questions