Home > Net >  TcpClient receiving and sending data is too small, how to expand the capacity
TcpClient receiving and sending data is too small, how to expand the capacity

Time:10-03

 
The client=New TcpClient ()
Client. The Connect (host, port)
The stream=client. GetStream ()
. Dim bytes () As Byte=Encoding UTF8. GetBytes (command. GetCommand () & amp; VbCrLf)

Stream. Write (0 bytes, bytes. The Length)
Stream. Flush ()
'ReDim bytes (Integer) MaxValue) can't set the maximum byte, TcpClient transmission limits the
'the ReDim bytes (client. ReceiveBufferSize)
ReDim bytes (62420)
Stream. Read (0 bytes, bytes. The Length)
Dim result=Encoding UTF8. Get string (bytes)

Do a DLL redis interface

CodePudding user response:

Can change the agreement to play, see your ID and the junction post rate, I don't want to say more

CodePudding user response:

reference 1st floor it_gz_xi response:
play can change the agreement, see your ID and the junction post rate, I don't want to say much

Eldest brother which deal with, to the don't understand
 
Public Sub New (Optional host As String="127.0.0.1", Optional port As an Integer=6379)
If IsNothing (host) Then
Throw New ArgumentNullException (NameOf (host))
End the If
Me. The Host=Host
Me. The Port=Port
The client=New TcpClient ()
Try
Client. The Connect (host, port)
The stream=client. GetStream ()
Catch the ex As Exception
Throw New RedisException (" An existing connection was forcibly closed by the remote host. ")
End the Try
End Sub
Private Sub Execute (command As IRedisCommand)
. Dim bytes () As Byte=Encoding UTF8. GetBytes (command. GetCommand () & amp; VbCrLf)
Try
Stream. Write (0 bytes, bytes. The Length)
Stream. Flush ()
'the ReDim bytes (Integer) MaxValue)
'the ReDim bytes (client. ReceiveBufferSize)
ReDim bytes (62420)
Stream. Read (0 bytes, bytes. The Length)
Dim result=Encoding UTF8. Get string (bytes)
The Select Case result (0)
Case "$"
Dim length=the Convert. ToInt32 (result. The Substring (1, result IndexOf (vbCrLf) - 1))
If the length=1 Then
Reply=New RedisReply (RESPType BulkString, Nothing)
The Else
Reply=New RedisReply (RESPType BulkString, result the Substring (result. IndexOf (vbCrLf) + 2, length))
End the If
The Case "+"
Reply=New RedisReply (RESPType SimpleString, result the Substring (1, result IndexOf (vbCrLf) - 1))
Case ":"
Reply=New RedisReply (RESPType. Integer, Convert ToInt32 (result. The Substring (1, result IndexOf (vbCrLf) - 1)))
Case ", "
Reply=New RedisReply (RESPType. The Error, the result, the Substring (1, result IndexOf (vbCrLf) - 1))
Throw New RedisException (Value) reply.
Case '*'
Dim count=the Convert. ToInt32 (result. The Substring (1, result IndexOf (vbCrLf) - 1))
Dim the items=result. The Split (New Char () {vbCrLf, vbLf}, StringSplitOptions. RemoveEmptyEntries). ToList ()
The items. The RemoveAt (0)
The items. RemoveAll (Function (I) i. tartsWith (" $"))
The items. The RemoveAt (items. The Count - 1)
Reply=New RedisReply (RESPType Array, the items)
End the Select
Catch the ex As Exception
Throw New RedisException ($" There is an internal error during executing '{command. GetCommand ()}'. ")
End the Try
End Sub
  • Related