...
Code Block | ||
---|---|---|
| ||
typedef void (*NETsocketCallback)(int SocketId);
void NETsetSocketWriteCallback(NETloopHandle LoopHane, NETsocketCallback pCallback);
void NETsetSocketReadCallback(NETloopHandle LoopHane, NETsocketCallback pCallback);
void NETsetSocketErrorCallback(NETloopHandle LoopHane, NETsocketCallback pCallback);
// NETpoll stays like this:
void NETpoll(NETloopHandle* pLoopHandle, int TimeoutInMilliseconds);
// And the read/write API stays like this:
int NETsocketRead(int SocketId, COLstring* pData);
int NETsocketWrite(int SocketId, const char* pData, int Size);
int NETsocketClose(int SocketId); |
Advantage of this model is possibly being more compatible with how IOCP works? Questions remain about how errors and socket closing would work in this model.
One might consider using COLclosures or similar callback mechanisms?
The general idea is that if a SocketId is no longer valid because the socket is closed that NETsocketRead/Write/Close would behave gracefully.