Played a little with sockets.

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@2539 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Robert Roebling 1999-05-22 10:11:03 +00:00
parent 7b90a8f20d
commit 6b3eb77aec
7 changed files with 31 additions and 6 deletions

View File

@ -130,7 +130,9 @@ class wxApp: public wxEvtHandler
wxWindow *m_topWindow;
gint m_idleTag;
#if wxUSE_THREADS
gint m_wakeUpTimerTag;
#endif
unsigned char *m_colorCube;
int argc;

View File

@ -130,7 +130,9 @@ class wxApp: public wxEvtHandler
wxWindow *m_topWindow;
gint m_idleTag;
#if wxUSE_THREADS
gint m_wakeUpTimerTag;
#endif
unsigned char *m_colorCube;
int argc;

View File

@ -27,6 +27,7 @@
#include "wx/socket.h"
#include "wx/url.h"
#include "wx/protocol/http.h"
#include "wx/thread.h"
#if defined(__WXMOTIF__) || defined(__WXGTK__)
#include "mondrian.xpm"

View File

@ -24,6 +24,7 @@
#endif
#include "wx/socket.h"
#include "wx/thread.h"
#if defined(__WXMOTIF__) || defined(__WXGTK__)
#include "mondrian.xpm"
@ -97,6 +98,11 @@ extern wxList wxPendingDelete;
void MyFrame::OnSockRequest(wxSocketEvent& evt)
{
/* this routine gets called from within the
waiting socket thread, i.e. here we are
not in the main GUI thread and thus we
must not call any GUI function here. */
wxSocketBase *sock = evt.Socket();
printf("OnSockRequest OK\n");
@ -111,7 +117,6 @@ void MyFrame::OnSockRequest(wxSocketEvent& evt)
break;
case wxSocketBase::EVT_LOST:
UpdateStatus(-1);
printf("Destroying socket\n");
wxPendingDelete.Append(sock);
return;
@ -123,10 +128,16 @@ void MyFrame::OnSockRequest(wxSocketEvent& evt)
void MyFrame::OnSockRequestServer(wxSocketEvent& evt)
{
/* this routine gets called from within the
waiting socket thread, i.e. here we are
not in the main GUI thread and thus we
must not call any GUI function here. */
wxSocketBase *sock2;
wxSocketServer *server = (wxSocketServer *) evt.Socket();
printf("OnSockRequestServer OK\n");
printf("OnSockRequest (event = %d)\n",evt.SocketEvent());
sock2 = server->Accept();
if (sock2 == NULL)
@ -136,7 +147,6 @@ void MyFrame::OnSockRequestServer(wxSocketEvent& evt)
sock2->Notify(TRUE);
sock2->SetEventHandler(*this, SKDEMO_SOCKET);
server->SetNotify(wxSocketBase::REQ_ACCEPT);
UpdateStatus(1);
}
// My frame Constructor

View File

@ -530,7 +530,6 @@ wxEvtHandler::~wxEvtHandler()
#ifdef __WXGTK__
extern bool g_isIdle;
extern void wxapp_install_idle_handler();
#endif
@ -554,7 +553,8 @@ bool wxEvtHandler::ProcessThreadEvent(wxEvent& event)
wxPendingEventsLocker->Leave();
#ifdef __WXGTK__
// if (g_isIdle) wxapp_install_idle_handler();
if (g_isIdle)
wxapp_install_idle_handler();
#endif
return TRUE;

View File

@ -215,7 +215,7 @@ void wxapp_install_idle_handler()
g_isIdle = FALSE;
}
#if wxUSE_THREADS
static gint wxapp_wakeup_timerout_callback( gpointer WXUNUSED(data) )
{
gtk_timeout_remove( wxTheApp->m_wakeUpTimerTag );
@ -242,6 +242,7 @@ static gint wxapp_wakeup_timerout_callback( gpointer WXUNUSED(data) )
return TRUE;
}
#endif
//-----------------------------------------------------------------------------
// wxApp
@ -262,7 +263,9 @@ wxApp::wxApp()
m_idleTag = gtk_idle_add( wxapp_idle_callback, (gpointer) NULL );
#if wxUSE_THREADS
m_wakeUpTimerTag = gtk_timeout_add( 10, wxapp_wakeup_timerout_callback, (gpointer) NULL );
#endif
m_colorCube = (unsigned char*) NULL;
}
@ -271,7 +274,9 @@ wxApp::~wxApp()
{
if (m_idleTag) gtk_idle_remove( m_idleTag );
#if wxUSE_THREADS
if (m_wakeUpTimerTag) gtk_timeout_remove( m_wakeUpTimerTag );
#endif
if (m_colorCube) free(m_colorCube);
}

View File

@ -215,7 +215,7 @@ void wxapp_install_idle_handler()
g_isIdle = FALSE;
}
#if wxUSE_THREADS
static gint wxapp_wakeup_timerout_callback( gpointer WXUNUSED(data) )
{
gtk_timeout_remove( wxTheApp->m_wakeUpTimerTag );
@ -242,6 +242,7 @@ static gint wxapp_wakeup_timerout_callback( gpointer WXUNUSED(data) )
return TRUE;
}
#endif
//-----------------------------------------------------------------------------
// wxApp
@ -262,7 +263,9 @@ wxApp::wxApp()
m_idleTag = gtk_idle_add( wxapp_idle_callback, (gpointer) NULL );
#if wxUSE_THREADS
m_wakeUpTimerTag = gtk_timeout_add( 10, wxapp_wakeup_timerout_callback, (gpointer) NULL );
#endif
m_colorCube = (unsigned char*) NULL;
}
@ -271,7 +274,9 @@ wxApp::~wxApp()
{
if (m_idleTag) gtk_idle_remove( m_idleTag );
#if wxUSE_THREADS
if (m_wakeUpTimerTag) gtk_timeout_remove( m_wakeUpTimerTag );
#endif
if (m_colorCube) free(m_colorCube);
}