Advertisement
apieceoffruit

TCP Code Snippit

Mar 23rd, 2021
867
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.57 KB | None | 0 0
  1.         public void SendAMessage(string message) {
  2.             if (_tcp == null) return;        
  3.            
  4.             try {          
  5.                 _printer.Sending(message);         
  6.                 var stream = _tcp.GetStream();
  7.                 if (!stream.CanWrite) return;
  8.                 var bytes = Encoding.GetBytes(message);
  9.                 stream.Write(bytes, 0, bytes.Length);                
  10.             }      
  11.             catch (SocketException socketException) {            
  12.                 _printer.Exception(socketException);        
  13.             }    
  14.         }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement