Hack Forums
[C#] [Socket] How do you think of this C# socket class? - Printable Version

+- Hack Forums (https://hackforums.net)
+-- Forum: Tech (https://hackforums.net/forumdisplay.php?fid=444)
+--- Forum: Coding (https://hackforums.net/forumdisplay.php?fid=151)
+---- Forum: Software Development (https://hackforums.net/forumdisplay.php?fid=118)
+---- Thread: [C#] [Socket] How do you think of this C# socket class? (/showthread.php?tid=4411967)



[Socket] How do you think of this C# socket class? - katetem - Aug 24, 2014

http://pastebin.com/tCDmb3bi

Can anyone find some problems for me to fix?


* - Assault - Aug 24, 2014

Code
public void Send(String data)
      {
            if (Started)
            {
            if (UseNewLine)
            data += "\r\n";
            // Convert the string data to byte data using ASCII encoding.
            byte[] byteData = Encoding.GetBytes(data);
            m_Socket.BeginSend(byteData, 0, byteData.Length, 0, CallBack_OnSend, null);
            }
      }

Eventually, this will lead to big problems.
What if you need to send over a string that has "\r\n" inside of it? Format the packet differently.


* - beta69 - Aug 24, 2014

That is the most horrific socket class I've ever seen in my entire life. If I had more time I'd bottleneck it, but it's over 600 lines and over half of them has to be at least deleted or reconstructured. This could have been done much more simpler, but good to see you learning.


* - Only3 - Aug 24, 2014

(Aug 24, 2014 02:00 PM)beta69 Wrote:  That is the most horrific socket class I've ever seen in my entire life.

nha u havent seen much then 😁


* - katetem - Aug 24, 2014

(Aug 24, 2014 02:00 PM)beta69 Wrote:  That is the most horrific socket class I've ever seen in my entire life. If I had more time I'd bottleneck it, but it's over 600 lines and over half of them has to be at least deleted or reconstructured. This could have been done much more simpler, but good to see you learning.

Could you point out wheres the problem instead of telling bulls?