return socket;
}
+void GSocket_close(GSocket *socket)
+{
+ _GSocket_Disable_Events(socket);
+ closesocket(socket->m_fd);
+ socket->m_fd = INVALID_SOCKET;
+}
+
void GSocket_destroy(GSocket *socket)
{
assert(socket != NULL);
if (socket->m_fd != INVALID_SOCKET)
{
shutdown(socket->m_fd, 2);
- closesocket(socket->m_fd);
- socket->m_fd = INVALID_SOCKET;
+ GSocket_close(socket);
}
/* Disable GUI callbacks */
socket->m_cbacks[evt] = NULL;
socket->m_detected = GSOCK_LOST_FLAG;
- _GSocket_Disable_Events(socket);
}
/* Address handling */
(SOCKLEN_T *)&sck->m_local->m_len) != 0) ||
(listen(sck->m_fd, 5) != 0))
{
- closesocket(sck->m_fd);
- sck->m_fd = INVALID_SOCKET;
+ GSocket_close(sck);
sck->m_error = GSOCK_IOERR;
return GSOCK_IOERR;
}
if (err != GSOCK_NOERROR)
{
- closesocket(sck->m_fd);
- sck->m_fd = INVALID_SOCKET;
+ GSocket_close(sck);
/* sck->m_error is set in _GSocket_Connect_Timeout */
}
/* If connect failed with an error other than EWOULDBLOCK,
* then the call to GSocket_Connect() has failed.
*/
- closesocket(sck->m_fd);
- sck->m_fd = INVALID_SOCKET;
+ GSocket_close(sck);
sck->m_error = GSOCK_IOERR;
return GSOCK_IOERR;
}
sck->m_local->m_addr,
(SOCKLEN_T *)&sck->m_local->m_len) != 0))
{
- closesocket(sck->m_fd);
- sck->m_fd = INVALID_SOCKET;
+ GSocket_close(sck);
sck->m_error = GSOCK_IOERR;
return GSOCK_IOERR;
}
typedef void (*wxDummy)();
#endif /* wxUSE_SOCKETS || defined(__GSOCKET_STANDALONE__) */
+
+// vi:sts=4:sw=4:et