* wxThread fixes

* wxStream fix (Read(wxStreamBase))
* wxEvent: GTK idle loop waking up was actually good, reenabled.
* wxSocket: all features working on Linux/RH6 (including high-level protocols)
       Needs testing on other platforms now.


git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@2563 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Guilhem Lavaux
1999-05-25 17:14:56 +00:00
parent 4d0f3cd6ac
commit 062c486171
11 changed files with 204 additions and 53 deletions

View File

@@ -3,7 +3,7 @@
* Purpose: wxSocket: client demo
* Author: LAVAUX Guilhem
* Created: June 1997
* Updated:
* CVS ID: $Id$
* Copyright: (c) 1997, LAVAUX Guilhem
*/
@@ -163,11 +163,8 @@ void MyFrame::OnExecOpenConnection(wxCommandEvent& WXUNUSED(evt))
if (sock->IsConnected())
sock->Close();
/*
wxString hname = wxGetTextFromUser("Enter the address of the wxSocket Sample Server",
"Connect ...", "localhost");
*/
wxString hname = "localhost";
addr.Hostname(hname);
addr.Service(3000);
sock->SetNotify(0);
@@ -282,13 +279,15 @@ void MyFrame::OnExecUrlTest(wxCommandEvent& WXUNUSED(evt))
wxURL url(urlname);
wxInputStream *datas = url.GetInputStream();
if (!datas)
wxMessageBox("Error in getting data from the URL.", "Alert !");
else {
if (!datas) {
wxString error;
error.Printf(_T("Error in getting data from the URL. (error = %d)"), url.GetError());
wxMessageBox(error, "Alert !");
} else {
wxFileOutputStream *str_out = new wxFileOutputStream("test.url");
str_out->Write(*datas);
wxMessageBox("Success !! Click on OK to see the text.", "OK");
wxMessageBox(_T("Success !! Click on OK to see the text."), "OK");
delete datas;
delete str_out;
}

View File

@@ -3,7 +3,7 @@
* Purpose: wxSocket: server demo
* Author: LAVAUX Guilhem
* Created: June 1997
* Updated:
* CVS Id: $Id$
* Copyright: (C) 1997, LAVAUX Guilhem
*/
@@ -102,6 +102,9 @@ void MyFrame::OnSockRequest(wxSocketEvent& evt)
waiting socket thread, i.e. here we are
not in the main GUI thread and thus we
must not call any GUI function here. */
/* Wrong ! This routine is called by the main GUI thread
because the main GUI thread received a signal from the other
thread using wxEvent::ProcessThreadEvent */
wxSocketBase *sock = evt.Socket();
@@ -119,6 +122,7 @@ void MyFrame::OnSockRequest(wxSocketEvent& evt)
case wxSocketBase::EVT_LOST:
printf("Destroying socket\n");
wxPendingDelete.Append(sock);
UpdateStatus(-1);
return;
break;
}
@@ -132,17 +136,21 @@ void MyFrame::OnSockRequestServer(wxSocketEvent& evt)
waiting socket thread, i.e. here we are
not in the main GUI thread and thus we
must not call any GUI function here. */
/* Wrong ! This routine is called by the main GUI thread
because the main GUI thread received a signal from the other
thread using wxEvent::ProcessThreadEvent */
wxSocketBase *sock2;
wxSocketServer *server = (wxSocketServer *) evt.Socket();
printf("OnSockRequestServer OK\n");
printf("OnSockRequest (event = %d)\n",evt.SocketEvent());
printf("OnSockRequest (Main = %d) (event = %d)\n",wxThread::IsMain(), evt.SocketEvent());
sock2 = server->Accept();
if (sock2 == NULL)
return;
UpdateStatus(1);
sock2->SetFlags(wxSocketBase::SPEED);
sock2->Notify(TRUE);
sock2->SetEventHandler(*this, SKDEMO_SOCKET);