The client.cs in Visual Studio.
private void SendToServer(string HeartRate)
{
SetHRTest(HeartRate);
try
{
s = client.
You are starting and shutting down the streams at every frame. Move your s, sr and sw initializations to the Start method and use OnApplicationQuit for closing.
void OnApplicationQuit()
{
s.Close();
soc.Close();
}
Doing so Unity will still hang as ReadLine is not asynchronous and will lock the execution until your socket receives data.
First two ways I can think of to go around this are:
I think it's the fact that you put all the server stuff in the Update. Which means it'll get called every frame. Which is a lot.
You should probably put all this in a separate method and call that from the client.