NetworkStream: 36 dòng GetStream TcpClient phương pháp () trả về một thể hiện của một NetworkStream, được sử dụng cho việc đọc và viết với socket của nó. Tiếp nhận và lặp lại dữ liệu cho đến khi khách hàng đóng cửa: đường 39-45 vòng lặp trong khi liên tục đọc các byte từ NetworkStream | The .NET Socket Class 45 Socket class requires the buffer argument to be preallocated to the appropriate size. If an attempt is made to receive more bytes into the buffer argument than has been allocated a SocketException will be thrown with the ErrorCode set to 10040 WinSock constant WSAEMSGSIZE and the Message set to Message too long. Throws ArgumentNullException ArgumentOutOfRangeException SocketException ObjectDisposedException. public static void Select IList readableList IList writeableList IList errorList int microseconds Used to determine the status of one or more Socket instances. This method takes between one and three IList container types holding Socket instances lists not passed should be set to null . What is checked for depends on the IList s position in the argument list. The Sockets in the first IList are checked for readability. The Sockets in the second IList are checked for writeability. The Sockets in the third IList are checked for errors. After completing only the Socket instances that meet the criteria will still be in the IList. The final argument is the time in microseconds to wait for a response. Throws ArgumentNullException SocketException. public int Send byte buffer public int Send byte buffer SocketFlags flags public int Send byte buffer int length SocketFlags flags public int Send byte buffer int offset int length SocketFlags flags Sends data to the Socket from the byte buffer argument. Optional arguments include SocketFlags an integer number of bytes to send and an integer offset in the buffer. Returns the number of bytes sent. Throws ArgumentNullException ArgumentOutOfRangeException SocketException ObjectDisposedException. public int SendTo byte buffer EndPoint remoteEP public int SendTo byte buffer SocketFlags flags EndPoint remoteEP public int SendTo byte buffer int length SocketFlags flags EndPoint remoteEP public int SendTo byte buffer int offset int length SocketFlags flags EndPoint remoteEP Sends a UDP datagram packet .