safakgur / socket-awaitable Goto Github PK
View Code? Open in Web Editor NEWAn easy-to-use library that provides socket utilities for taking advantage of async/await operators.
License: MIT License
An easy-to-use library that provides socket utilities for taking advantage of async/await operators.
License: MIT License
Why do we have to call Task.Delay()? That make the library unreliable. I tried to send and receive messages, and since I did not use Delay, the messages that I was getting was not truly real. And I use Delay (because of the test sample) and I got the real message. This is really a big deal/issue.
Hi,
I tried to apply SocketAwaitable as a Socket Client by send & receive data to Server with 5 seconds receive timeout , below is code i using
using (var client = new Socket(SocketType.Stream, ProtocolType.Tcp))
{
client.ReceiveTimeout = 5000;
using (var connectAwaitable = new SocketAwaitable())
{
connectAwaitable.RemoteEndPoint = new IPEndPoint(IPAddress.Parse(_remoteIP), _remotePort);
var connectResult = await client.ConnectAsync(connectAwaitable);
}
// Send.
using (var sendAwaitable = new SocketAwaitable())
{
sendAwaitable.Buffer = new ArraySegment<byte>(data);
var sendResult = await client.SendAsync(sendAwaitable);
}
using (var recvAwaitable = new SocketAwaitable())
{
recvAwaitable.Buffer = new ArraySegment<byte>(new byte[512]);
var respResult = await client.ReceiveAsync(recvAwaitable);
if (respResult == SocketError.Success)
{
response = recvAwaitable.Transferred.Array;
}
}
`}`
I tried to set server side to response socket client after 10 seconds but my socket client never throw Socket Timeout exception. Could you help to advice?
After testing with many connections, the server can not accept connections as many as it runs first time. the amount of subsequent connections depends on the total reusable SocketAwaitable minus the prior connected clients. The shutdown SocketAwaitable objects were put back to the pool.
Any ideas?
(Sorry to pose the question here as an issue if it isn't appropriate.)
I'm wondering if it's okay to call SendAsync multiple times w/o having any code to synchronize the calls. I imagine it can be an issue if I try to send a packet that is too large to be sent in 1 shot and needs to be sent in pieces while another thread is also potentially sending at the same time. Is this correct? What would be recommended approach to being able to synchronize sending?
Great work on this library btw. I've been looking for someone to explain how to properly do a single buffer/pooling and was having a tough time until I saw your project.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.