John Labenski wrote: (Wed, 28 Oct 2009 19:07:17 -0700) >On Wed, Oct 28, 2009 at 2:28 PM, lostgallifreyan ><lostgallifre...@gmail.com> wrote: >> I got it! >:) At least, I really think so.... >> >> function Main() >> local IP=wx.wxIPV4address() IP:AnyAddress() IP:Service(80) >> local SKT=wx.wxSocketServer(IP,wx.wxSOCKET_NONE) >> print("Socket OK?",SKT:Ok()) >> >> FRAME=wx.wxFrame(wx.NULL,-1,"") FRAME:SetSize(432,310) FRAME:Centre() >> >> SKT:SetEventHandler(FRAME,wx.wxEVT_SOCKET) >> SKT:SetNotify(-1,wxSOCKET_CONNECTION_FLAG) >> SKT:Notify(true) >> FRAME:Connect(-1,wx.wxEVT_SOCKET,function(E) print("!!!!!") end) >> >> FRAME:Show(true) >> end >> >> Main() >> >> >> That lets me know if I connect to the right IP and port. I'm still not >> exactly sure what prompted me to try exactly this, it was a half-baked >> interpretatiojn of something in wx.chm, but it WORKS. Question is, is it >> right? Can it be simplified? Is it formally correct? Please let me know. >> John >> (Labensky), you've been silent for a long time, but I'd like you to say >> something now. I got far enough on my own since Andreas Krink gave me the >> starting help with a proven example of basic socket access, so havign got >> here I want to know if I did it the right way. Please let me know if this is >> missing something I should know, or confirm that it is correct. It obviously >> works, but I didn't design this system so what works now might not always do >> so unless it fits with proper methods. > >I really don't know as I haven't used the wxWidgets socket code very >much. What you did looks fairly straightforward though.
That works for me. :) Thankyou. Btw, John, remember that MIDI thing I asked about? There might be a neat way round this. (Requires yes/no answer, I won't go into detail now other than saying why I want to know..) Does wxLua allow us to set an arbitrary serial port baud setting? Like 31.25 kb? I've learned that Sparkfun's Logomatic v2 hardware can do this with two serial ports so potential fun lies that way if I learn more C, but even nicer would be doing it in wxLua if I set that baud rate. Adapting a serial port on a PC to do MIDI hardware is a lot easier than learning C. >Thanks to the >others for chiming in. > Seconded. Without Andreas' examples I don't know when, or even if, I'd have motivated myself enough to find a solution to the event connection, never mind the rest of it. Btw, two small changes seem to be needed in that code: omit IP:AnyAddress() as this is default state anyway, it allows anyone to connect unless I bind to a remote IP with some yet-unlearned function. Also, add SKT:Accept(false) to the handler function's code to either immediately handle the incoming (waiting) client request, or at least free up the socket instantly if the client isn't there, so it's ready for a new connection. ------------------------------------------------------------------------------ Come build with us! The BlackBerry(R) Developer Conference in SF, CA is the only developer event you need to attend this year. Jumpstart your developing skills, take BlackBerry mobile applications to market and stay ahead of the curve. Join us from November 9 - 12, 2009. Register now! http://p.sf.net/sfu/devconference _______________________________________________ wxlua-users mailing list wxlua-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/wxlua-users