From e51b0130934f0c289629c36c7c93ab3d60c63d7b Mon Sep 17 00:00:00 2001 From: Guillermo Rodriguez Garcia Date: Fri, 3 Mar 2000 19:22:35 +0000 Subject: [PATCH] small mods git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@6420 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- samples/sockets/client.b32 | 16 +++++++ samples/sockets/client.cpp | 17 ++++--- samples/sockets/makefile.b32 | 88 +++++------------------------------- samples/sockets/makefile.g95 | 41 +++-------------- samples/sockets/server.b32 | 16 +++++++ samples/sockets/server.cpp | 11 +++-- 6 files changed, 66 insertions(+), 123 deletions(-) create mode 100644 samples/sockets/client.b32 create mode 100644 samples/sockets/server.b32 diff --git a/samples/sockets/client.b32 b/samples/sockets/client.b32 new file mode 100644 index 0000000000..dc09ca1d17 --- /dev/null +++ b/samples/sockets/client.b32 @@ -0,0 +1,16 @@ +# +# File: makefile.b32 +# Author: Julian Smart +# Created: 1999 +# Updated: +# Copyright: +# +# Makefile : Builds sample for 32-bit BC++ + +WXDIR = $(WXWIN) + +TARGET=client +OBJECTS = $(TARGET).obj + +!include $(WXDIR)\src\makeprog.b32 + diff --git a/samples/sockets/client.cpp b/samples/sockets/client.cpp index ab5d91ed38..d418cd5955 100644 --- a/samples/sockets/client.cpp +++ b/samples/sockets/client.cpp @@ -79,7 +79,7 @@ public: // event handlers for Protocols menu void OnTestURL(wxCommandEvent& event); - // event handlers for DatagramSocket menu + // event handlers for DatagramSocket menu (stub) void OnDatagram(wxCommandEvent& event); // socket event handler @@ -210,7 +210,7 @@ MyFrame::MyFrame() : wxFrame((wxFrame *)NULL, -1, CreateStatusBar(2); // Make a panel with a textctrl in it - m_panel = new wxPanel(this, -1, wxPoint(0, 0), GetClientSize()); + m_panel = new wxPanel(this, -1); m_text = new wxTextCtrl(m_panel, -1, _("Welcome to wxSocket demo: Client\n" "Client ready\n"), @@ -302,10 +302,10 @@ void MyFrame::OnOpenConnection(wxCommandEvent& WXUNUSED(event)) // // Connect(addr, FALSE); // WaitOnConnect(seconds, millis); - // success = IsConnected(); + // bool success = IsConnected(); // // And that's all :-) - // + m_text->AppendText(_("\nTrying to connect (timeout = 10 sec) ...\n")); m_sock->Connect(addr, FALSE); m_sock->WaitOnConnect(10); @@ -349,7 +349,7 @@ void MyFrame::OnTest1(wxCommandEvent& WXUNUSED(event)) // value larger than a byte "as is" across the network, or // you might be in trouble! Ever heard about big and little // endian computers?) - // + m_sock->SetFlags(wxSOCKET_WAITALL); buf1 = _("Test string (less than 256 chars!)"); @@ -405,7 +405,7 @@ void MyFrame::OnTest2(wxCommandEvent& WXUNUSED(event)) // // We need to set no flags here (ReadMsg and WriteMsg are // not affected by flags) - // + m_sock->SetFlags(wxSOCKET_WAITALL); wxString s = wxGetTextFromUser( @@ -472,7 +472,7 @@ void MyFrame::OnTest3(wxCommandEvent& WXUNUSED(event)) // large buffer so that wxSocket is actually forced to split // it into pieces and take care of sending everything before // returning. - // + m_sock->SetFlags(wxSOCKET_WAITALL); // Note that len is in kbytes here! @@ -518,6 +518,9 @@ void MyFrame::OnCloseConnection(wxCommandEvent& WXUNUSED(event)) void MyFrame::OnDatagram(wxCommandEvent& WXUNUSED(event)) { + m_text->AppendText(_("=== Datagram test begins ===")); + m_text->AppendText(_("Sorry, not implemented")); + m_text->AppendText(_("=== Datagram test ends ===")); } void MyFrame::OnTestURL(wxCommandEvent& WXUNUSED(event)) diff --git a/samples/sockets/makefile.b32 b/samples/sockets/makefile.b32 index 47c572e8a2..b9aac16acc 100644 --- a/samples/sockets/makefile.b32 +++ b/samples/sockets/makefile.b32 @@ -1,83 +1,17 @@ # -# File: makefile.b32 -# Author: Guilhem Lavaux -# Created: 1998 +# File: makefile.vc +# Author: Julian Smart +# Created: 1999 # Updated: -# Copyright: (c) Guilhem Lavaux +# Copyright: (c) Julian Smart # -# "%W% %G%" -# -# Makefile : Builds 32-bit wxSocket sample under BC++ +# Makefile : Builds sample for 32-bit BC++ -WXDIR = $(WXWIN) - -ZLIB = $(WXDIR)\lib\zlib.lib -XPMLIB = $(WXDIR)\lib\xpm.lib - -!include $(WXDIR)\src\makeb32.env - -WXLIBDIR = $(WXDIR)\lib -WXINC = $(WXDIR)\include\msw -WXLIB = $(WXLIBDIR)\wx32.lib -LIBS=$(WXLIB) $(ZLIB) $(XPMLIB) cw32 import32 ole2w32 - -!if "$(FINAL)" == "0" -LINKFLAGS=/v /Tpe /L$(WXLIBDIR);$(BCCDIR)\lib -OPT = -Od -DEBUG_FLAGS= -v -!else -LINKFLAGS=/Tpe /L$(WXLIBDIR);$(BCCDIR)\lib -OPT = -Od -DEBUG_FLAGS = -!endif -CPPFLAGS=$(DEBUG_FLAGS) $(OPT) @$(CFG) - -.$(SRCSUFF).obj: - bcc32 $(CPPFLAGS) -c {$< } - -.c.obj: - bcc32 $(CPPFLAGS) -P- -c {$< } - -CLIENT_TARGET=client -SERVER_TARGET=server -CLIENT_OBJECTS=client.obj -SERVER_OBJECTS=server.obj - -all: $(CLIENT_TARGET).exe $(SERVER_TARGET).exe - -$(CLIENT_TARGET).exe: $(CLIENT_OBJECTS) $(CLIENT_TARGET).res - tlink32 $(LINKFLAGS) @&&! - c0w32.obj $(CLIENT_OBJECTS) - $(CLIENT_TARGET) - nul - $(LIBS) - $(CLIENT_TARGET).def - $(CLIENT_TARGET).res -! - -client.obj: client.cpp - -$(CLIENT_TARGET).res : $(CLIENT_TARGET).rc $(WXDIR)\include\wx\msw\wx.rc - brc32 -r /i$(BCCDIR)\include /i$(WXDIR)\include $(CLIENT_TARGET) - -$(SERVER_TARGET).exe: $(SERVER_OBJECTS) $(SERVER_TARGET).res - tlink32 $(LINKFLAGS) @&&! - c0w32.obj $(SERVER_OBJECTS) - $(SERVER_TARGET) - nul - $(LIBS) - $(SERVER_TARGET).def - $(SERVER_TARGET).res -! - -server.obj: server.cpp - -$(SERVER_TARGET).res: $(SERVER_TARGET).rc $(WXDIR)\include\wx\msw\wx.rc - brc32 -r /i$(BCCDIR)\include /i$(WXDIR)\include $(SERVER_TARGET) +all: + make -f server.b32 all + make -f client.b32 all clean: - -erase *.obj - -erase *.exe - -erase *.res - -erase *.map - -erase *.rws + make -f server.b32 clean + make -f client.b32 clean + diff --git a/samples/sockets/makefile.g95 b/samples/sockets/makefile.g95 index 4d1b5983be..40343ddace 100644 --- a/samples/sockets/makefile.g95 +++ b/samples/sockets/makefile.g95 @@ -1,5 +1,5 @@ # -# File: makefile.unx +# File: makefile.g95 # Author: Julian Smart # Created: 1993 # Updated: @@ -9,38 +9,11 @@ # # Makefile for server/client example (UNIX). -WXDIR = ../.. - -# All common UNIX compiler flags and options are now in -# this central makefile. -include $(WXDIR)/src/makeg95.env - -OBJECTS=$(OBJDIR)/server.$(OBJSUFF) $(OBJDIR)/server_resources.$(OBJSUFF)\ - $(OBJDIR)/client.$(OBJSUFF) $(OBJDIR)/client_resources.$(OBJSUFF) - -all: $(OBJDIR) server$(GUISUFFIX) client$(GUISUFFIX) - - -$(OBJDIR): - mkdir $(OBJDIR) - -server$(GUISUFFIX): $(OBJDIR)/server.$(OBJSUFF) $(OBJDIR)/server_resources.$(OBJSUFF) $(WXLIB) - $(CC) $(LDFLAGS) -o server$(GUISUFFIX)$(EXESUFF) $(OBJDIR)/server.$(OBJSUFF) $(OBJDIR)/server_resources.$(OBJSUFF) $(LDLIBS) - -$(OBJDIR)/server.$(OBJSUFF): server.$(SRCSUFF) - $(CC) -c $(CPPFLAGS) -o $@ server.$(SRCSUFF) - -client$(GUISUFFIX): $(OBJDIR)/client.$(OBJSUFF) $(OBJDIR)/client_resources.$(OBJSUFF) $(WXLIB) - $(CC) $(LDFLAGS) -o client$(GUISUFFIX)$(EXESUFF) $(OBJDIR)/client.$(OBJSUFF) $(OBJDIR)/client_resources.$(OBJSUFF) $(LDLIBS) - -$(OBJDIR)/client.$(OBJSUFF): client.$(SRCSUFF) - $(CC) -c $(CPPFLAGS) -o $@ client.$(SRCSUFF) - -$(OBJDIR)/server_resources.o: server.rc - $(RESCOMP) -i server.rc -o $(OBJDIR)/server_resources.o $(RESFLAGS) - -$(OBJDIR)/client_resources.o: client.rc - $(RESCOMP) -i client.rc -o $(OBJDIR)/client_resources.o $(RESFLAGS) +all: + make -f client.g95 all + make -f server.g95 all clean: - rm -f $(OBJECTS) server$(GUISUFFIX).exe client$(GUISUFFIX).exe core *.rsc *.res + make -f client.g95 clean + make -f server.g95 clean + diff --git a/samples/sockets/server.b32 b/samples/sockets/server.b32 new file mode 100644 index 0000000000..ea052fb474 --- /dev/null +++ b/samples/sockets/server.b32 @@ -0,0 +1,16 @@ +# +# File: makefile.b32 +# Author: Julian Smart +# Created: 1999 +# Updated: +# Copyright: +# +# Makefile : Builds sample for 32-bit BC++ + +WXDIR = $(WXWIN) + +TARGET=server +OBJECTS = $(TARGET).obj + +!include $(WXDIR)\src\makeprog.b32 + diff --git a/samples/sockets/server.cpp b/samples/sockets/server.cpp index f24529f16c..ca2a897285 100644 --- a/samples/sockets/server.cpp +++ b/samples/sockets/server.cpp @@ -171,7 +171,7 @@ MyFrame::MyFrame() : wxFrame((wxFrame *)NULL, -1, CreateStatusBar(2); // Make a panel with a textctrl in it - m_panel = new wxPanel(this, -1, wxPoint(0, 0), GetClientSize()); + m_panel = new wxPanel(this, -1); m_text = new wxTextCtrl(m_panel, -1, _T("Welcome to wxSocket demo: Server\n"), wxPoint(0, 0), m_panel->GetClientSize(), @@ -230,7 +230,7 @@ void MyFrame::Test1(wxSocketBase *sock) // exact size and use the wxSOCKET_WAITALL flag. Also, we // disabled input events so we won't have unwanted reentrance. // This way we can avoid the infamous wxSOCKET_BLOCK flag. - // + sock->SetFlags(wxSOCKET_WAITALL); sock->Read((char *)&len, 1); @@ -255,7 +255,7 @@ void MyFrame::Test2(wxSocketBase *sock) // We don't need to set flags because ReadMsg and WriteMsg // are not affected by them anyway. - // + len = sock->ReadMsg(buf, MAX_MSG_SIZE).LastCount(); s.Printf(_T("Client says: %s\n"), buf); @@ -278,7 +278,7 @@ void MyFrame::Test3(wxSocketBase *sock) // This test is similar to the first one, but the len is // expressed in kbytes - this tests large data transfers. - // + sock->SetFlags(wxSOCKET_WAITALL); sock->Read((char *)&len, 1); @@ -307,7 +307,7 @@ void MyFrame::OnServerEvent(wxSocketEvent& event) // connections queue, else exit. We use Accept(FALSE) for // non-blocking accept (although if we got here, there // should ALWAYS be a pending connection). - // + sock = m_server->Accept(FALSE); if (sock) @@ -375,6 +375,7 @@ void MyFrame::OnSocketEvent(wxSocketEvent& event) // We cannot delete the socket right now because we can // be in the middle of a test or something. So we append // it to the list of objects to be deleted. + m_text->AppendText(_T("Deleting socket.\n")); wxPendingDelete.Append(sock); break;