Mario Steele
2007-Oct-29 11:02 UTC
[wxruby-development] wxRuby Socket Demo finally available
Hello All, I''ve just sent off the source code for wxRuby Socket''s demo to Sean and Alex to do some final testing on Linux and MacOS X, to ensure compatability of my design with those two operating systems. Once confirmed, the demo will be posted to the SVN. What is basically entailed within these two demos, is the implementation of a Server with a GUI Front End, and the implementation of a Client with a GUI Front End. I targeted it after a very simple Chat Program, with simple text based communication, but should be able to work with Binary data as well. The main 2 source codes to look at, is wxServer.rb and wxClient.rb (Which are the ones you want to run as well.) I''ve simplified the code a bit, separating it into different libraries, so one library is primly for the GUI Creation (Which is shared between both Server and Client), as well as the slight modification to the Socket''s class, adding the methods Socket#recv_packet() and Socket#send_packet() which just ensures that there''s no Buffered IO Reading, and ensures that data being sent, has a Line Feed (0x0A) at the end, which shows that it''s the end of the packet the server or client is sending. Any questions, comments, suggestions, feel free to email me. L8ers, Mario Steele
Alex Fenton
2007-Oct-29 11:59 UTC
[wxruby-development] wxRuby Socket Demo finally available
Mario Steele wrote:> What is basically > entailed within these two demos, is the implementation of a Server with > a GUI Front End, and the implementation of a Client with a GUI Front > End. I targeted it after a very simple Chat Program, with simple text > based communication, but should be able to work with Binary data as > well.I''ve just checked this into SVN: http://wxruby.rubyforge.org/svn/trunk/wxruby2/samples/sockets/ Thanks very much to Mario for this; it''s an interesting sample and well worth a look to see how to do network and threaded coding while keeping the GUI responsive. cheers alex
Mario, Nice work on that sample. I had to make a few tweaks to get it to run on OS X. The first was a crash when you try changing your username or start the server caused by position_to_xy returning nil instead of 0. On Windows and Linux 0 is returned (as it should be per the official wxWidget docs). The second was using localhost as the address, again it works fine on Windows and Linux, I used 127.0.0.1 instead for OS X. Sean On 10/29/07, Alex Fenton <alex at pressure.to> wrote:> Mario Steele wrote: > > What is basically > > entailed within these two demos, is the implementation of a Server with > > a GUI Front End, and the implementation of a Client with a GUI Front > > End. I targeted it after a very simple Chat Program, with simple text > > based communication, but should be able to work with Binary data as > > well. > I''ve just checked this into SVN: > http://wxruby.rubyforge.org/svn/trunk/wxruby2/samples/sockets/ > > Thanks very much to Mario for this; it''s an interesting sample and well > worth a look to see how to do network and threaded coding while keeping > the GUI responsive. > > cheers > alex > _______________________________________________ > wxruby-development mailing list > wxruby-development at rubyforge.org > http://rubyforge.org/mailman/listinfo/wxruby-development >
Mario Steele
2007-Oct-29 18:31 UTC
[wxruby-development] wxRuby Socket Demo finally available
Hey Sean, Thanks for the tips, I''ll make the tweaks to my code here, and submit it to the SVN, along with a patch I''m currently working on when the client attempts to connect to an address where no server is running on, and it shows a successful connection, but when it attempts to write to it, it throws a Pipe Error. Hope to have those in by the end of the day. Mario Sean Long wrote:> Mario, > > Nice work on that sample. > > I had to make a few tweaks to get it to run on OS X. The first was a > crash when you try changing your username or start the server caused > by position_to_xy returning nil instead of 0. On Windows and Linux 0 > is returned (as it should be per the official wxWidget docs). The > second was using localhost as the address, again it works fine on > Windows and Linux, I used 127.0.0.1 instead for OS X. > > Sean >
I already checked in my little changes, commit #1389. Look forward to your other changes. Sean On 10/29/07, Mario Steele <mario at ruby-im.net> wrote:> Hey Sean, > > Thanks for the tips, I''ll make the tweaks to my code here, and submit it > to the SVN, along with a patch I''m currently working on when the client > attempts to connect to an address where no server is running on, and it > shows a successful connection, but when it attempts to write to it, it > throws a Pipe Error. Hope to have those in by the end of the day. > > Mario > > Sean Long wrote: > > Mario, > > > > Nice work on that sample. > > > > I had to make a few tweaks to get it to run on OS X. The first was a > > crash when you try changing your username or start the server caused > > by position_to_xy returning nil instead of 0. On Windows and Linux 0 > > is returned (as it should be per the official wxWidget docs). The > > second was using localhost as the address, again it works fine on > > Windows and Linux, I used 127.0.0.1 instead for OS X. > > > > Sean > > > _______________________________________________ > wxruby-development mailing list > wxruby-development at rubyforge.org > http://rubyforge.org/mailman/listinfo/wxruby-development >
Mario Steele
2007-Oct-29 20:55 UTC
[wxruby-development] wxRuby Socket Demo finally available
Hey Sean, Can you confirm for me, if on MacOS X, the Pipe Error occurs as well, when you launch the client without the server, and try connecting? Thanks, Mario Steele Sean Long wrote:> I already checked in my little changes, commit #1389. > > Look forward to your other changes. > > Sean > > On 10/29/07, Mario Steele <mario at ruby-im.net> wrote: > >> Hey Sean, >> >> Thanks for the tips, I''ll make the tweaks to my code here, and submit it >> to the SVN, along with a patch I''m currently working on when the client >> attempts to connect to an address where no server is running on, and it >> shows a successful connection, but when it attempts to write to it, it >> throws a Pipe Error. Hope to have those in by the end of the day. >> >> Mario >>
If I launch the client and then try connecting I get this in the status window: Attempting to connect to 127.0.0.1:1234 Connected to 127.0.0.1:1234 No crash. If I then try changing the user name I get: ./SocketPackets.rb:25:in `write'': Broken pipe (Errno::EPIPE) HTH Sean On 10/29/07, Mario Steele <mario at ruby-im.net> wrote:> Hey Sean, > > Can you confirm for me, if on MacOS X, the Pipe Error occurs as well, > when you launch the client without the server, and try connecting? > > Thanks, > > Mario Steele > > > Sean Long wrote: > > I already checked in my little changes, commit #1389. > > > > Look forward to your other changes. > > > > Sean > > > > On 10/29/07, Mario Steele <mario at ruby-im.net> wrote: > > > >> Hey Sean, > >> > >> Thanks for the tips, I''ll make the tweaks to my code here, and submit it > >> to the SVN, along with a patch I''m currently working on when the client > >> attempts to connect to an address where no server is running on, and it > >> shows a successful connection, but when it attempts to write to it, it > >> throws a Pipe Error. Hope to have those in by the end of the day. > >> > >> Mario > >> > _______________________________________________ > wxruby-development mailing list > wxruby-development at rubyforge.org > http://rubyforge.org/mailman/listinfo/wxruby-development >
Mario Steele
2007-Oct-29 21:13 UTC
[wxruby-development] wxRuby Socket Demo finally available
Hey Sean, Yep, that''s what I was looking for. Looks like this is localized to Linux type OS''. I''ll have a patch for it very soon. Thanks, Mario Sean Long wrote:> If I launch the client and then try connecting I get this in the status window: > Attempting to connect to 127.0.0.1:1234 > Connected to 127.0.0.1:1234 > > No crash. > > If I then try changing the user name I get: > ./SocketPackets.rb:25:in `write'': Broken pipe (Errno::EPIPE) > > HTH > > Sean >
Mario Steele
2007-Oct-29 22:41 UTC
[wxruby-development] wxRuby Socket Demo finally available
Hey Sean and Alex, Could you please try out the recent patch I did on wxClient.rb, to see if the Broken Pipe error comes up. Currently, I have two test cases in which causes the socket thread to stop working all together. The steps are below: Test Case 1: Run the client without the server, attempt to connect, and it should display the error Actively refused. Launch the Server, attempt to connect, and it''ll freeze saying it connected, but no connection shown on the Server, and no data will transmit. Test Case 2: Start Client and Server, start the server, connect to it, enter data if you want, disconnect from the server, shutdown the server, but leave it running, attempt to connect the client, no error message is displayed like it is suppose to be. Could you confirm these test results, to see if the same problem occurs on your end, as it has on my test enviroment? Thanks, Mario Sean Long wrote:> If I launch the client and then try connecting I get this in the status window: > Attempting to connect to 127.0.0.1:1234 > Connected to 127.0.0.1:1234 > > No crash. > > If I then try changing the user name I get: > ./SocketPackets.rb:25:in `write'': Broken pipe (Errno::EPIPE) > > HTH > > Sean >
Alex Fenton
2007-Oct-29 23:08 UTC
[wxruby-development] wxRuby Socket Demo finally available
Hi Mario Steele wrote:> Could you please try out the recent patch I did on wxClient.rb, to see > if the Broken Pipe error comes up.Yes, this fixes the BrokenPipe error on Linux. Thanks.> Test Case 1: > Run the client without the server, attempt to connect, and it should > display the error Actively refused. Launch the Server, attempt to > connect, and it''ll freeze saying it connected, but no connection shown > on the Server, and no data will transmit. >This seems to work correctly. After I launch the server (and start it), and trying connecting from the client, it doesn''t say "Connected" after "Attempting...". But data does transmit, and on the server side it says "Client connected". Also, if I stop and restart the server, I get: samples/sockets/wxServer.rb:102:in `bind'': Address already in use - bind(2) (Errno::EADDRINUSE) from samples/sockets/wxServer.rb:102:in `on_start'' ...> Test Case 2: > Start Client and Server, start the server, connect to it, enter data if > you want, disconnect from the server, shutdown the server, but leave it > running, attempt to connect the client, no error message is displayed > like it is suppose to be.Yes, I can reproduce this on Linux. When I then try and send some data from the client, I get ./samples/sockets/SocketPackets.rb:25:in `write'': Connection refused (Errno::ECONNREFUSED) from ./samples/sockets/SocketPackets.rb:25:in `send_packet'' ... hth alex PS - please could you set your editor to indent with two physical spaces, not tabs when committing to the wxRuby SVN repo? Thanks.
Mario Steele
2007-Oct-29 23:24 UTC
[wxruby-development] wxRuby Socket Demo finally available
Hey, Alex Fenton wrote:> Yes, this fixes the BrokenPipe error on Linux. Thanks. >Great.>> Test Case 1: >> Run the client without the server, attempt to connect, and it should >> display the error Actively refused. Launch the Server, attempt to >> connect, and it''ll freeze saying it connected, but no connection shown >> on the Server, and no data will transmit. >> >> > This seems to work correctly. After I launch the server (and start it), > and trying connecting from the client, it doesn''t say "Connected" after > "Attempting...". But data does transmit, and on the server side it says > "Client connected". >Actually found, that if I run connect twice, before starting the server, then follow through with the connection, it freezes up the poll thread.> Also, if I stop and restart the server, I get: > > samples/sockets/wxServer.rb:102:in `bind'': Address already in use - > bind(2) (Errno::EADDRINUSE) > from samples/sockets/wxServer.rb:102:in `on_start'' ..This is not a good thing, I''ll have to look at that as well...> Yes, I can reproduce this on Linux. When I then try and send some data > from the client, I get > > ./samples/sockets/SocketPackets.rb:25:in `write'': Connection refused > (Errno::ECONNREFUSED) > from ./samples/sockets/SocketPackets.rb:25:in `send_packet'' ... >This is what I was afraid of, that it wasn''t just on my test enviroment, I can''t figure out why this is occuring, as I put in a /eval command into the Command Processor, to evaluate some instance data, and as far as I can tell, Threads are created properly, and destroyed properly. You can check by running /eval Thread.list, which will print out the array of threads currently created within the scope of the program. Ofcourse, not enough processing going on, to show that the thread created for polling the Socket, is actually running, it just shows sleeping, as the context switch is to quick to catch.> hth > alex > > PS - please could you set your editor to indent with two physical > spaces, not tabs when committing to the wxRuby SVN repo? ThanksNot a problem, I have to add that capability to my editor that I''m using. LOL I''m using wxRIDE to develop itself in, as well as the Demos, so I''ll add that capability, and fix it to use spaces. Thanks for the confirmation, and if you could check what I suggested above for the first test case. Attempting to connect a couple to three times, before starting the server, and actually doing a successful connect, might confirm what I''m afraid of. L8ers, Mario Steele -------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/wxruby-development/attachments/20071029/9b314112/attachment.html
Alex Fenton
2007-Oct-30 08:50 UTC
[wxruby-development] wxRuby Socket Demo finally available
Mario Steele wrote:> Attempting to connect a couple to three times, before starting the > server, and actually doing a successful connect, might confirm what > I''m afraid of.Tried 3 connects without server, then started a server, connected, disconnected, attempted to reconnect. Results: first connection with server present seems to work correctly, as does disconnect. Second connection with server (still) present doesn''t fail or succeed. Data''s transmitted from client, but Server can''t see client''s name. Eval Thread.list on client says: [#<Thread:0xb5263990 sleep>, #<Thread:0xb7e047d4 run>] hth alex
Mario Steele
2007-Oct-30 12:17 UTC
[wxruby-development] wxRuby Socket Demo finally available
Okay, that may just be a problem with the speed at which I do the connects, not allowing the thread to fully clear itself, or some sort of thing like that. But the other problem, still bothers me quite a bit, and from what I can tell of my own code, there is no fault with the logic of it. I may have to re-write the code, to see if I can track this down to being a Thread problem, or it being a Mutex lock problem of some sort, something not being unlocked...... Which I think I may have just figured out the problem. I will write back in a few if this works.... L8ers, Mario Steele Alex Fenton wrote:> Mario Steele wrote: > >> Attempting to connect a couple to three times, before starting the >> server, and actually doing a successful connect, might confirm what >> I''m afraid of. >> > Tried 3 connects without server, then started a server, connected, > disconnected, attempted to reconnect. > > Results: first connection with server present seems to work correctly, > as does disconnect. Second connection with server (still) present > doesn''t fail or succeed. Data''s transmitted from client, but Server > can''t see client''s name. > > Eval Thread.list on client says: > [#<Thread:0xb5263990 sleep>, #<Thread:0xb7e047d4 run>] > > hth > alex > > _______________________________________________ > wxruby-development mailing list > wxruby-development at rubyforge.org > http://rubyforge.org/mailman/listinfo/wxruby-development > >-------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/wxruby-development/attachments/20071030/a221f82c/attachment-0001.html