sorry for my bad english ….. this is good, but it only works in local IP … have you some examples (Windows Form) about chat for 2 or 3 PC over internet with different connection ? … thanks
@wolfscrygames4 жыл бұрын
Hello, I have some examples but it's hard for me to test right now before I get back to you on this. There are different issues depending on the operating system. Are you working with Windows, Mac, or Linux?
@NickFromIT4 жыл бұрын
@@wolfscrygames WIndows (10)
@wolfscrygames4 жыл бұрын
@@NickFromIT have you set up port forwarding on the host computer's network?
@NickFromIT4 жыл бұрын
@@wolfscrygames i dont know how ... i need to see or read .... take your time ... I'm in no hurry :-)
@wolfscrygames4 жыл бұрын
@@NickFromIT we've identified the issue. To connect from an external network, you need to host with the local address and connect with the external address. You also need to do port forwarding in most cases because routers block incoming traffic. Instructions are different for each router and internet provider, but the concept is the same. Lastly, verify the host PC is not blocking inbound traffic with firewall. You can either turn off the firewall or set up a rule to allow incoming traffic.
@FlanderDev Жыл бұрын
Bruh, this Video is pure gold. THANK YOU SO MUCH.
@brodyentertainment6605 Жыл бұрын
Exactly what i was looking for. Explained it perfectly and still working 3 years later. Thanks!!
@zeph0shade2 жыл бұрын
I'm only halfway through it so far but already wanna say I appreciate this video immensely. As someone who has ADHD and has been repeatedly hyperfocused on learning to code games for over a year, I am often extremely dissatisfied with how hard it can be to find tutorials that are TRULY teaching the subject at the most basic level. I've been interested in learning to build multiplayer games for quite a while, yet have made zero progress in months because of how much info out there assumes what you really want is a pre-built networking solution. I'll settle for templates and prebuilt solutions AFTER I'm satisfied that I understand what they're really doing under the hood, and to understand that, I need more content like this. Thank you!
@wolfscrygames2 жыл бұрын
I'm glad you found it helpful. Keep up the good work!
@somerandomguywastaken2 жыл бұрын
Thank you for the detailed breakdown. Its so hard to try understand the raw code without any understanding of networking syntax. Thanks!!!!!!!
@wolfscrygames2 жыл бұрын
Happy to have helped
@viviengemai97963 жыл бұрын
Thanks, I needed a simple and clear explanation. Searching for System.Net / Sockets etc. did mostly turn up useless junk or ASP.Net even though all I needed was communication between applications for an internal network with C# alone. I'll see if I can set this up tomorrow. The goal is for an async polling to handle the client communication to the server when the database is updated to ensure any database change gets an instant update for all registered clients/IPs in the network. Your tutorial looks to be what I needed.
@wolfscrygames3 жыл бұрын
Sounds like it'll work out. Good luck!
@AddColors2525 Жыл бұрын
It was easy even for me as a beginner software engineer to understand. Thank you!
@olotolow4 жыл бұрын
Very good explained and a tcp connection is actually way easier then i thought.
@wolfscrygames4 жыл бұрын
Glad it helped! Took me a while to get the hang of it, but you're right, tcp connections are definitely easy enough to handle.
@RoberBot2 жыл бұрын
This is awesome, finally someone that explains what hes doing You are awesome
@aba221252 жыл бұрын
I'm an advanced networking user, but kinda new to C# networking in particular, and this tutorial was amazing, thank you dude. Btw, you should teach about encryption -- I don't see any tutorials covering it, it's just a simple plaintext communication, which is a hella bad idea if you're going to allow external connections.
@wolfscrygames2 жыл бұрын
Thanks for the feedback. I'll definitely think about encryption topics for the future, but I will need to brush up on best practices since that can be a critical topic for scaling up a company. I have a rock paper scissors royale tutorial ready to go. Should be re-recorded and public by the weekend if you're interested.
@paulanerspezi1634 Жыл бұрын
Really nice tutorial! Works perfectly fine after 3 years!
@btc763 жыл бұрын
excellent video, thanks for this !! I will try and adapt your teachings to C# WPF app now :)
@MaxIzrin3 жыл бұрын
Might have to use this. Every connectivity package out there relies on players being in the same scene, and that's just not something I can rely on, since I have an asymmetric simulation. Good video, thanks.
@edgarbarnett83483 жыл бұрын
Very helpful and easy to follow. Keep up the great job!
@benzeyne994 жыл бұрын
very helpful and well explained video, thanks!
@wolfscrygames4 жыл бұрын
Happy to be of service. Hope it works the way you want it to.
@benzeyne994 жыл бұрын
@@wolfscrygames it worked out great, using the StreamReader and StreamWriter was the missing piece of the puzzle.
@shara62812 жыл бұрын
Thanks for the Video, very helpful and well explained !
@wolfscrygames2 жыл бұрын
Glad it helped out.
@martinavallsrodriguez43214 жыл бұрын
Thanks ,very well explained and helpful!
@b0x32 жыл бұрын
بيض الله وجهك يالامير 🌹
@maurice38554 жыл бұрын
Helped a lot! Thank you sir
@wolfscrygames4 жыл бұрын
Glad to be of service
@ryujinjakka83853 жыл бұрын
This video helped me alot, thanks
@wolfscrygames3 жыл бұрын
Glad to help out
@Video-ep4ij3 жыл бұрын
why are we adding +1 to messageToSend variable while calculating byte size?
@shubhamsati31453 жыл бұрын
Thanks man it helped me understand the networking a little bit. I was really having a hard time finding some basic tutorials. Could you make a video about connecting unity clients to a dedicated server.
@samuelward90583 жыл бұрын
This works in unity aswell. Me: just realized this is a 4 month old comment 😅
@algum5042 жыл бұрын
i have never worked with streams (don't usually use Visual Studio, but have to check if VS can connect and communicate with our existing non-VS server) but i hope it has status functions (call read only if something is in stream) else it will just lock up the program if you are just waiting to read something
@wolfscrygames2 жыл бұрын
Streamreader and streamwriter just let you work with strings instead of byte arrays. Non-blocking sockets can be used, in which case you'll need to check status. Blocking sockets do prevent code progression like you mentioned.
@hiagomarcal50004 жыл бұрын
Thank you.
@wolfscrygames4 жыл бұрын
Glad to be of service
@badactor96283 жыл бұрын
really useful thanks
@twiddle71254 жыл бұрын
Great video. Can the server be connected to multiple clients simultaneously?
@wolfscrygames4 жыл бұрын
Thanks! Yes, multiple clients can connect at the same time. Each client will connect through TCP using its IP Address behind the scenes.
@twiddle71254 жыл бұрын
@@wolfscrygames Great, thank you. Now I have to find an equivalent video for python, lol.
@noobicalcuriosity34363 жыл бұрын
man ur very helpful
@rasmingabriellefiestada23573 жыл бұрын
Hello, i tried this today and whenever i run it, on the client app, it only says (request received) without the "My name is Minmin"' .. can u pls help..?
@CuteRay3 жыл бұрын
Thx bro 😎
@gonzalolo11 ай бұрын
Hello there! I've been working on setting up a TCP system for streaming VR videos on Oculus. I've had trouble connecting from outside my network and your video explanation really helped. Do you think TCP is a good choice for my project? I plan to turn it into an asset, but I'm concerned about users having to deal with router setups for P2P connections. Any suggestions? Thanks a lot for your video!
@wolfscrygames11 ай бұрын
Hello, You may be interested in looking up "nat hole punching".
@gonzalolo11 ай бұрын
@@wolfscrygames thanks mate, will check it up right now!
@gonzalolo11 ай бұрын
Mmm thing is , i want it to be p2p and i dont want to involve a 3rd party over the process, so this approach looks like it doesnt fit my needs :/ , but thanks a lot
@wolfscrygames11 ай бұрын
For p2p, they'll need to either configure their networks or make simultaneous requests. A 3rd party in hole punching handles the synchronization, then allows the two clients to communicate independent of server. The main server only does the handshake to start the connection.
@gonzalolo11 ай бұрын
@@wolfscrygamesthanks for your answers :)!, im using photon fusion service, the service should have a special capability? or can i do the handshake just with an RPC?
@olivieraudet-yang75763 жыл бұрын
thx! :)
@wolfscrygames3 жыл бұрын
Happy to be of service
@bynarie2 жыл бұрын
NEVER, EVER, EVER use a goto statement. Great tutorial, except the goto statement. These are NOT needed. Just wrap your code into a function, and then call it again from within the catch() block. Thanks!
@wolfscrygames2 жыл бұрын
I appreciate the input, but goto statements are like salt: fine when used sparingly but harmful in excess. As you can see, a single goto is not going to produce spaghetti code. It's more clear for learners than a while loop and it's certainly more clear than a function that calls itself.
@Eithanz2 жыл бұрын
in the server, you have sr but you dont use the streamreader???
@iQuickGaming3 жыл бұрын
i made an application and the data gets sent once but the second time i try sending something it doesnt work
@JG-wv6bj2 жыл бұрын
I know it's been a while, but I just stumbled across this to assist with an issue I was having and I found a slight issue with the code in the description. In the server-side code you've declared the string for the request but then done nothing with it. You need to include the request string in the line below otherwise the users won't see the messageToSend from the client.
@wolfscrygames2 жыл бұрын
Good idea! That would definitely increase clarity.
@migthundra22 жыл бұрын
How would you modify this to allow you to receive protocol buffer serials?
@siavashmehmandoost21983 жыл бұрын
Thanks for your amazing tutorial! I successfully connected my client on unity to server. I'm new to networking. how to transfer another data such as player position, destruction of players, reducing health etc. Could you please help me through your own client script please?
@wolfscrygames3 жыл бұрын
Hello, This was meant to be an introduction, and I haven't done too much experimenting with networking in unity yet, but basically you need to create a protocol for transferring data. A simple example would be to add a prefix to any data you want to send, then parse(split) and handle it with switch statements. If the prefix is 0, that might mean player position was sent, or if the prefix is 1, maybe player health was sent, etc. Since this system can be confusing, it's best to use an enum instead of integers to keep your code readable.
@siavashmehmandoost21983 жыл бұрын
@@wolfscrygames Thanks man! It'd be great if you could create a video focusing on that. I saw a tutorial focusing on transferring data based on tcp and asynchronous but It's just a bunch of words and codes without any explanation. You know I can just copy and paste that code, But I want to do it by myself! I saw an asset in Unity store named FMETP. is it helpful? assetstore.unity.com/packages/templates/packs/fmetp-stream-143080#reviews
@wolfscrygames3 жыл бұрын
@@siavashmehmandoost2198 I might be able to put something together. That asset you linked looks like it's for video streaming. You might be more interested in Forge Networking, Mirror networking, or PUN2.
@BdyPhrk3 жыл бұрын
How to fix Unable to read data from the transport connection: An existing connection was forcibly closed by the remote host ?
@wolfscrygames3 жыл бұрын
Sounds like a firewall issue. Any time you open a network connection, it needs to be allowed by firewall as it is technically an inherent security vulnerability.
@erickcarballo14542 жыл бұрын
Excuse me, this can be use in WinForms?
@wolfscrygames2 жыл бұрын
It's a standard c# feature, so it would also work in forms. That being said, ensure your network appropriately allows incoming traffic, otherwise the data won't get past the router.
@johnmarkremotigue89853 жыл бұрын
My server didn't receive the message "My name is Neo"
@thisguythatguyify3 жыл бұрын
Hey, how do I use this to connect to another computer? if I change the Ip address I get an error System.Net.Sockets.SocketException: 'The requested address is not valid in its context'
@wolfscrygames3 жыл бұрын
drive.google.com/file/d/1T_rn-3OWFhfdInJvBjwGlSIlMhPm8cMd/view You can format it as you see in this screenshot and it should accept your ip address.
@wolfscrygames3 жыл бұрын
There's a comment below with a long thread where I discussed in more detail. I'm on my phone and it won't let me copy it for you.
@zkkmtadndavideolar1493 жыл бұрын
this is not only for LAN right ?
@wolfscrygames3 жыл бұрын
No, it also works for public, but you have to change the way you write in your ip address so the computer established a public socket instead of a local socket. Also, the client has to connect to the public ip address and port forwarding is required in the router setup.
@zaebalzaebal28204 жыл бұрын
Why you just dont make it while(true) all your code rather then that goto?
@wolfscrygames4 жыл бұрын
There's nothing inherently wrong with goto statements, although they are generally cautioned against because of misuse. As long as goto statements are used sparingly and sensibly, they can make code easy to read. A while(true) should accomplish the same task. Goto can also be used to exit a nested for loop instead of doing break; if (condition) break; In this case, the goto statement just reminds me at the bottom of my code that I'm going back to the top.
@hajkotv55584 жыл бұрын
So it will work in my LAN? Also with more clients? Thanks for answer
@wolfscrygames4 жыл бұрын
Yes, you just need to type the ip part differently for it to work outside localhost. On server use the local ip, 192.168.x.x, on client use the external ip aka public ip. Don't share these values with others as they should be private.
When I try to run the server on a different device in my house the client cant connect to the server. Pls help
@wolfscrygames3 жыл бұрын
If it's all on the same network, you just need the server ip address. If it's on a different network, such as cell service, you need to use port forwarding.
@rbxretro69773 жыл бұрын
@@wolfscrygames I’m new to this networking. What is port forwarding?
@wolfscrygames3 жыл бұрын
@@rbxretro6977 you're going to need the information to log into your router. It's usually printed on a sticker on the side of the router. Basically, your router has a built in firewall and denies all incoming traffic unless you form the connection first. To turn off the firewall on one port(out of about 65000) you designate a port and send all traffic for your app to that port. Your router then sends it to your pc. You can look up instructions for your specific router model.
@rbxretro69773 жыл бұрын
@@wolfscrygames how do you send all the traffic to the port?
@wolfscrygames3 жыл бұрын
@@rbxretro6977 port forwarding. You'll have to look up that part on your own since everyone has different routers.
@skymix52743 жыл бұрын
Hi i know is late but Can i use it to trojan programs?
@wolfscrygames3 жыл бұрын
A Trojan is just a program in disguise, so in a way, probably. I wouldn't recommend writing Trojans as you can get into serious legal trouble.
@skymix52743 жыл бұрын
@@wolfscrygames its a ask i Will dont use it to it i only ask
@pollomagico2713 жыл бұрын
@@skymix5274 its just for a friend huh
@user-vc1bk4fw7e4 жыл бұрын
can you give me the code of the unity chaat ??please
@wolfscrygames4 жыл бұрын
@@user-vc1bk4fw7e The code is in the description
@user-vc1bk4fw7e4 жыл бұрын
@@wolfscrygames IN UNITY .PLEASE
@donfoumare4 жыл бұрын
5:27 Well, I saw more or less the same example code (lines 18-20) in other "tutorials" with almost the same variable names which to me looks like copy & paste. Why on earth do you first allocate memory with the new operator, assign that to sendData and than assign something else to sendData? What's the point of lines 18 and 19? Do you even know the basics? Things like "what is a variable", "what does the 'new' operator do", "what does the '=' operator do"...
@wolfscrygames4 жыл бұрын
I do it because it works. It's okay to have your own coding style and it's actually preferred practice to copy and paste. When the code is the same in multiple places, it makes it easier to find solutions when problems come up.
@donfoumare4 жыл бұрын
@@wolfscrygames While it is convenient to reuse code so you don't have to reinvent the wheel each time, you should make sure the code you copied is ok. Especially if you use it for educational purposes. Having an own "coding style" is one thing, but arbitrarily allocating unnecessary memory for no reason is just bad programming. Despite that, it is too obvious that the 'new byte[..]' instruction is unnecessary, unless you don't know how assignments work. Even if the compiler removes the instructions as part of it's optimizations it will still be in the source code for no reason. While i'm writing this i realize that i maybe overreact a bit but I saw this in a couple of videos in the last hours.. I know nobody is perfect and you may be a beginner in programming (i don't know you) but you should double-check your sources in the future before using them. And while programming looks like an easy task these days with all the frameworks, libraries, tutorials and sources in the internet, it is still worth to take the time and dig somewhat deeper to fully understand what happens behind the scenes. This will help you to avoid errors, make your code more efficient, more reliable, makes it easier to find bugs and to maintain the code.
@wolfscrygames4 жыл бұрын
@@donfoumare I'll look into removing those two lines. I'm a high school teacher full time and often only have 10-30 minutes to make these videos. Thanks to Coronavirus I now have a unique opportunity with schools closing to work on my channel. I started programming 3 years ago, and this topic is something that was hard to learn and hard to find info for.