SimpleTCP icon indicating copy to clipboard operation
SimpleTCP copied to clipboard

SimpleTcpClient.WriteAndGetReply?

Open rualmar opened this issue 6 years ago • 4 comments

I've been using this framework for a while for simple TCP communications (thanks a lot for making our life easy), but I've reached a point where I need to send a message and listen for the reply synchronously. I've tested with SimpleTcpClient method WriteLineAndGetReply but the problem is that this method inserts a trailing line end char at the end of the string I'm sending, and the thid party system which I'm sending messages to does not support it. Is there any way to remove the final char? Something like WriteAndGetReply?

Thanks.

Edit: (early sending) I've been testing the implementation by copying the code for the method WriteLineAndGetReply and replacing the WriteLine(data) with Write(data). If you see it interesting I may fork the repository and send a pull request with the method WriteAndGetReply.

rualmar avatar Apr 05 '18 09:04 rualmar

I'd love to see this feature, I'm currently working on a project where this would be extremely useful

michaelgaultjr avatar May 12 '18 02:05 michaelgaultjr

All messages received have "‼" (a double exclamation point in a single character) added on to the end of it. Is this the same issue you're referring to?

matt1tk avatar Jul 29 '20 21:07 matt1tk

If so, use

message.MessageString.Remove(message.MessageString.Length-1, 1)

not

message.MessageString

matt1tk avatar Jul 30 '20 00:07 matt1tk

This part of your code will not work: if (data.LastOrDefault() != Delimiter) { Write(data + StringEncoder.GetString(new byte[] { Delimiter })); }

And this: delimiter = 0x13; <---- is wrong, the right way is: delimiter = 0x0D; or just delimiter = 13; Because you are comparing LastOrDefault (which is a char), with a delimiter (which is a byte), and you are always adding a delimiter to the end

GnRSlash avatar Mar 15 '22 15:03 GnRSlash