Share via


socket send newline char

Question

Tuesday, May 29, 2012 2:18 AM

Dear all,

I have below code. How to send the newline char in socket send??

                        string fileName =XMLFilesPath + txn + ".xml";

                        socket client;

                        string line;
                        System.IO.StreamReader file = new System.IO.StreamReader(fileName);
                        while ((line = file.ReadLine()) != null)
                        {
                            byte[] msg = Encoding.UTF8.GetBytes(line + "\n");   // not valid of "\n";
                            int byteCount = client.Send(msg, SocketFlags.None);
                        }

                        file.Close();

All replies (2)

Tuesday, May 29, 2012 2:23 AM âś…Answered

Solved by putting "\r\n"


Wednesday, May 30, 2012 1:59 AM

Hi ,

 Great job ,thanks for sharing  and have a  nice day!

Lisa Zhu [MSFT]
MSDN Community Support | Feedback to us