0

I have a simple client/server set up that works fine if the client and server are running on the same machine over localhost.

The code I am using for now can be seen here:

https://msdn.microsoft.com/en-us/library/bew39x2a(v=vs.110).aspx (client)

and

https://msdn.microsoft.com/en-us/library/fx6588te.aspx (server)

When I am running the server on a different machine, it is still over an isolated network wherein the only 2 devices connected are the client and the server.

The server will continuously throw the errors

"An existing connection was forcibly closed by the remote host" (most often) 

and

"Only one usage of each socket address is permitted"

I have Windows Firewall disabled on the server machine.

One other strange thing the server will sometimes do is repeatedly echo the line "Waiting for connection" - You can see this line inside the 'StartListening()' function in the Server code.

Justin
  • 533
  • 1
  • 7
  • 18
  • The "strange thing" in your final paragraph isn't that odd - servers are meant to service multiple clients (generally) so as soon as it accepts a connection to one client, it starts trying to accept connections from other clients - and that is indeed what that code implements. – Damien_The_Unbeliever Jul 31 '15 at 13:51
  • Yes that would be normal if it proceeded with processing the connection, but it doesn't, it literally echos "Waiting for connection" as many times as a client tries to connect, then proceeds to sit there. After some time has passed it may throw the error that the connection was forcibly closed after a timeout period for each "Waiting" that it echoed. And I say it is strange because there are no messages between the "Waiting for connection" - it will just have 5 of them in a row sometimes. – Justin Jul 31 '15 at 13:52
  • Well.. I added a "Thread.Sleep(200);" just after the 'BeginConnect' call on the client side... now the server appears to process everything normally. – Justin Jul 31 '15 at 14:59
  • Now even more silly, if I run the server using IIS Express it works like a charm. If I use regular IIS, it can't figure its life out... Not sure why that would be. – Justin Jul 31 '15 at 16:54
  • Please [edit] your question to add more information - and bear in mind that my commenting is just to try to help you improve your question. I'm not sure that trying to host a socket server from within an IIS hosted application makes the most sense - so you may want to expand on your overall goals here, also. – Damien_The_Unbeliever Jul 31 '15 at 17:29

0 Answers0