Guidance
指路人
g.yi.org
Guidance Forums / wxWidgets (wxWindows) in C++ / wxDatagramSocket with Shared Pointers

Register 
注册
Search 搜索
首页 
Home Home
Software
Upload

  
Forum List • Thread List • Reply • Refresh • New Topic • Search • Previous • Next First 1 Last
Message1. wxDatagramSocket with Shared Pointers
#4189
Posted by: Ken 2004-05-20 02:03:56
Hello,

I am trying to model a thermal switch used on a solar car for the school science fair. I need to get this done ASAP because I have to submit this code to my partner so she can use it to do testing. When called, the default constructor does the following:

1) Creates a socket on port 0x5344 (listens on this port) (thermal_address)
2) It sends a stream of 'X' chars to port 0x5345 to a Java applet (serverAddress)

Below is the simplifed code. The sendto function doesn't do anything. Nothing gets sent. Even when I packet sniff UDP port 0x5345 and disable the Java Applet.

There is one private field called _socket which is defined below:

// The same as wxDatagramSocket * _socket (from www.boost.org)
shared_ptr<wxDatagramSocket> _socket;

//Constructor ---- simplifided
thermal_switch() {
  
   //Get IP Addresses of local machine
   if ( (thermal_address.AnyAddress( )) && (serverAddress.LocalHost( )) )
      { OUTPUT( "IP addresses are good "); }
     
   //Assign Ports
   if ( (serverAddress.Service((unsigned short)0x5345)) && (thermal_address.Service((unsigned short)0x5344)) )
      { OUTPUT( "Listening to ports"); }
     
   // This is the same as _socket = new wxDatagramSocket(thermal_address) from www.boost.org
   _socket = shared_ptr< wxDatagramSocket > (new wxDatagramSocket(thermal_address) );
     
   //Check and see if socket is OK
   if( _socket->Ok( ) )
      { OUTPUT("Socket created"); }
   else
      { OUTPUT("FATAL ERROR IN UDP SOCKET LISTENER"); }
  
   // Test Data
   char stream_of_x[50];
   for (int z = 0; z <= 49; z++) { stream_of_x[z] = 'X'; }
  
   //Sending to server port
   _socket->SendTo(serverAddress, stream_of_x, sizeof(stream_of_x) );
   OUPUT("Sending");

   //Error
   if (_socket->Error())  { OUTPUT("TRANSMISSION OF THERMAL SWITCH CONTENTS FAILED"); }
    
}

----
Thanks,
Ken

quais_100@hotmail.com
Message2. RPC. Question   .NOT XML RPC
#4275
Posted by: 2004-05-28 23:08:39
Hello,

Has anyone successfully implemented the RPC/XDR library set using the philosophy of the WxWidgets

abstraction(s)?

And do you want to share the code??

Thank You
Forum List • Thread List • Reply • Refresh • New Topic • Search • Previous • Next First 1 Last
掌柜推荐
 
 
 
 
 
 
 
 
 
 
 
 
© Sat 2024-10-5  Guidance Laboratory Inc.
Email:webmaster1g.yi.org Hits:0