Need help with my server-client application
Hello, I am creating a server - client programm using Tcp. However, I am encoutering a problem where I gets an error called: System.IO.IOException: 'Unable to read data from the transport connection: An existing connection was forcibly closed by the remote host..' from the server while loop each time after I have received a message notifying whether I had entered a correct username and a correct password. The following is the while loop i am talking about
5 Replies
it could be that the issue is in client part
you're checking for
resultExamCode.Equals("Not found")
twice aside from that we would need more $code to see what else is going onTo post C# code type the following:
```cs
// code here
```
Get an example by typing
$codegif
in chat
For longer snippets, use: https://paste.mod.gg/it could be the size of the message being split in multiple packets, it could be your logic on the other side ending and closing the socket
all I can tell is that one side or the other terminated the socket
are u sure u got the whole message before actually processing it?
with stream based protocols u have to account for not getting the whole message at once, or even more than just one message.
eg if the server sends "hello world" and then "how are you doing?",
u could receive it as "hell" and then start processing, or u could receive "hello worldhow are you", etc
as we do not know much about the server itself i can only guess.
but usually if the server abruptly closes the connection its a protocol error of some kine (eg sending invalid packets), as in the protocol on top of tcp, not tcp itself
oh wait u mentioned that u r writing both sides 😒
yeah show us both ends of the connection