private void socketUpdate(int events)
{
ScopedTimer.Ping();
lock (close_mutex)
{
if (closed) return;
}
if (is_server)
{
TcpTransport transport = accept();
if (transport != null)
{
if (accept_cb == null) throw new Exception("NULL ACCEPT_CB FTL!");
accept_cb(transport);
}
}
else
{
if ((events & POLLIN) != 0 && expecting_read) //POLL IN FLAG
{
if (read_cb != null)
{
read_cb(this);
}
}
if ((events & POLLOUT) != 0 && expecting_write)
{
if (write_cb != null)
write_cb(this);
}
if ((events & POLLERR) != 0 || (events & POLLHUP) != 0 || (events & POLLNVAL) != 0)
{
int error = 0;
try
{
error = (int) sock.GetSocketOption(SocketOptionLevel.Socket, SocketOptionName.Error);
}
catch (Exception e)
{
EDB.WriteLine("Failed to get sock options! (error: " + error + ")" + e);
}
if (error != 0)
EDB.WriteLine("SOCKET ERROR = " + error);
close();
}
}
}