-
Hello Everyone! I am using SocketConnectionFactory in Kestrel. I don't know how to read data after creating a Socket. I've been looking at the source code for a long time, and I haven't made any progress. Who can provide a simple and efficient way to read data or protocols? public static async void RunSocket()
{
var endpoit = new IPEndPoint(IPAddress.Parse("127.0.0.1"), 8989);
var factory = new SocketConnectionFactory(new SocketTransportOptions());
var connection = factory .ConnectAsync(endpoit).Result;
ReadData(connection);
Send(connection);
}
public static async void ReadData(ConnectionContext connection)
{
//while(true) ?
//how to code ??
}
public static async void Send(ConnectionContext connection)
{
while (true)
{
var temp = Console.ReadLine();
if (temp != null)
{
var buffer = Encoding.UTF8.GetBytes(temp);
await connection.Transport.Output.WriteAsync(buffer);
}
}
} |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments
-
Kestrel is so complex that I have to embed code in the ProcessReceives method. ......
var result = await flushTask;
if (paused)
{
//_trace.ConnectionResume(ConnectionId);
}
// ↓ I added code like this :
_receiver._awaitableEventArgs.ReadBuffer(buffer); But this is obviously wrong. What is the best practice? |
Beta Was this translation helpful? Give feedback.
-
Is anyone here? |
Beta Was this translation helpful? Give feedback.
-
I had got the answer from a new issue. |
Beta Was this translation helpful? Give feedback.
I had got the answer from a new issue.