It seems like that dataFromClient does not contains "$" and that's why
dataFromClient.IndexOf("$")
is returning -1 which causing
dataFromClient.Substring(0, dataFromClient.IndexOf("$"))
to throw "Length cannot be less than zero" exception.
Please debug and check it.