Search code examples
c#socketsnetwork-programmingserverclient

Multiple clients connecting to a server


I am trying to write a server in C# for connecting Unity clients following a guy's tutorial. I'll start by saying that I don't know much about networking, as I am trying to learn during the process. When I run the server (on the localhost) it begins to accept tcp clients through an Async callback, and so when I try to connect via browser by doing "http://localhost:port/", the incoming connection describes 3 clients:

enter image description here

my question is: why?? when I connect from unity through a script, the incoming connection is only one: the player, as it should be.

the server code that I am using: https://github.com/tom-weiland/tcp-udp-networking/tree/tutorial-part1/GameServer/GameServer

It would be really appreciated if you could provide an explanation of how the callbacks work, as while debugging it was weird to see that the lines were running multiple times.


Solution

  • When you try to connect over HTTP, the browser makes 3 default calls. First, it does an OPTIONS request to get the web server's configuration. Then it get a GET / to get the root webpage. The third thing it does it GET /favicon.ico for the icon on your browser tab. Additional calls may also be made if you have images, stylesheets, or other external content specified on the page.