Changed void GSocket_Init() to bool GSocket_Init()
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@3168 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -76,7 +76,7 @@ extern "C" {
|
|||||||
/* Global initialisers */
|
/* Global initialisers */
|
||||||
|
|
||||||
/* GSocket_Init() must be called at the beginning */
|
/* GSocket_Init() must be called at the beginning */
|
||||||
void GSocket_Init();
|
bool GSocket_Init();
|
||||||
/* GSocket_Cleanup() must be called at the ending */
|
/* GSocket_Cleanup() must be called at the ending */
|
||||||
void GSocket_Cleanup();
|
void GSocket_Cleanup();
|
||||||
|
|
||||||
|
@@ -912,8 +912,7 @@ class WXDLLEXPORT wxSocketModule: public wxModule {
|
|||||||
DECLARE_DYNAMIC_CLASS(wxSocketModule)
|
DECLARE_DYNAMIC_CLASS(wxSocketModule)
|
||||||
public:
|
public:
|
||||||
bool OnInit() {
|
bool OnInit() {
|
||||||
GSocket_Init();
|
return GSocket_Init();
|
||||||
return TRUE;
|
|
||||||
}
|
}
|
||||||
void OnExit() {
|
void OnExit() {
|
||||||
GSocket_Cleanup();
|
GSocket_Cleanup();
|
||||||
|
@@ -34,7 +34,6 @@
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include <signal.h>
|
#include <signal.h>
|
||||||
/* #include <features.h> */
|
|
||||||
|
|
||||||
#include "wx/setup.h"
|
#include "wx/setup.h"
|
||||||
#include "wx/gsocket.h"
|
#include "wx/gsocket.h"
|
||||||
@@ -54,8 +53,9 @@
|
|||||||
|
|
||||||
/* Global initialisers */
|
/* Global initialisers */
|
||||||
|
|
||||||
void GSocket_Init()
|
bool GSocket_Init()
|
||||||
{
|
{
|
||||||
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
void GSocket_Cleanup()
|
void GSocket_Cleanup()
|
||||||
@@ -84,6 +84,7 @@ GSocket *GSocket_new()
|
|||||||
socket->m_gui_dependent = NULL;
|
socket->m_gui_dependent = NULL;
|
||||||
socket->m_blocking = FALSE;
|
socket->m_blocking = FALSE;
|
||||||
|
|
||||||
|
/* We initialize the GUI specific entries here */
|
||||||
_GSocket_GUI_Init(socket);
|
_GSocket_GUI_Init(socket);
|
||||||
|
|
||||||
return socket;
|
return socket;
|
||||||
@@ -93,17 +94,21 @@ void GSocket_destroy(GSocket *socket)
|
|||||||
{
|
{
|
||||||
assert(socket != NULL);
|
assert(socket != NULL);
|
||||||
|
|
||||||
|
/* First, we check that the socket is really shutdowned */
|
||||||
if (socket->m_fd != -1)
|
if (socket->m_fd != -1)
|
||||||
GSocket_Shutdown(socket);
|
GSocket_Shutdown(socket);
|
||||||
|
|
||||||
|
/* We destroy GUI specific variables */
|
||||||
_GSocket_GUI_Destroy(socket);
|
_GSocket_GUI_Destroy(socket);
|
||||||
|
|
||||||
|
/* We destroy private addresses */
|
||||||
if (socket->m_local)
|
if (socket->m_local)
|
||||||
GAddress_destroy(socket->m_local);
|
GAddress_destroy(socket->m_local);
|
||||||
|
|
||||||
if (socket->m_peer)
|
if (socket->m_peer)
|
||||||
GAddress_destroy(socket->m_peer);
|
GAddress_destroy(socket->m_peer);
|
||||||
|
|
||||||
|
/* We destroy socket itself */
|
||||||
free(socket);
|
free(socket);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -113,12 +118,14 @@ void GSocket_Shutdown(GSocket *socket)
|
|||||||
|
|
||||||
assert(socket != NULL);
|
assert(socket != NULL);
|
||||||
|
|
||||||
|
/* If socket has been created, we shutdown it */
|
||||||
if (socket->m_fd != -1) {
|
if (socket->m_fd != -1) {
|
||||||
shutdown(socket->m_fd, 2);
|
shutdown(socket->m_fd, 2);
|
||||||
close(socket->m_fd);
|
close(socket->m_fd);
|
||||||
socket->m_fd = -1;
|
socket->m_fd = -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* We also disable GUI callbacks */
|
||||||
for (evt=0;evt<GSOCK_MAX_EVENT;evt++)
|
for (evt=0;evt<GSOCK_MAX_EVENT;evt++)
|
||||||
_GSocket_Uninstall_Fallback(socket, evt);
|
_GSocket_Uninstall_Fallback(socket, evt);
|
||||||
}
|
}
|
||||||
@@ -129,11 +136,15 @@ GSocketError GSocket_SetLocal(GSocket *socket, GAddress *address)
|
|||||||
{
|
{
|
||||||
assert(socket != NULL);
|
assert(socket != NULL);
|
||||||
|
|
||||||
if ((socket->m_fd != -1 && !socket->m_server))
|
if ((socket->m_fd != -1 && !socket->m_server)) {
|
||||||
|
socket->m_error = GSOCK_INVSOCK;
|
||||||
return GSOCK_INVSOCK;
|
return GSOCK_INVSOCK;
|
||||||
|
}
|
||||||
|
|
||||||
if (address == NULL || address->m_family == GSOCK_NOFAMILY)
|
if (address == NULL || address->m_family == GSOCK_NOFAMILY) {
|
||||||
|
socket->m_error = GSOCK_INVADDR;
|
||||||
return GSOCK_INVADDR;
|
return GSOCK_INVADDR;
|
||||||
|
}
|
||||||
|
|
||||||
if (socket->m_local)
|
if (socket->m_local)
|
||||||
GAddress_destroy(socket->m_local);
|
GAddress_destroy(socket->m_local);
|
||||||
@@ -566,7 +577,6 @@ int _GSocket_Recv_Stream(GSocket *socket, char *buffer, int size)
|
|||||||
int _GSocket_Recv_Dgram(GSocket *socket, char *buffer, int size)
|
int _GSocket_Recv_Dgram(GSocket *socket, char *buffer, int size)
|
||||||
{
|
{
|
||||||
struct sockaddr from;
|
struct sockaddr from;
|
||||||
|
|
||||||
SOCKLEN_T fromlen;
|
SOCKLEN_T fromlen;
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user