wxSocketClient::Connect behavior, MAC OS X 10.6 vs. Win32

If you are using the main C++ distribution of wxWidgets, Feel free to ask any question related to wxWidgets development here. This means questions regarding to C++ and wxWidgets, not compile problems.
Post Reply
tedzini
Knows some wx things
Knows some wx things
Posts: 34
Joined: Tue Apr 20, 2010 2:30 pm

wxSocketClient::Connect behavior, MAC OS X 10.6 vs. Win32

Post by tedzini » Tue Jan 25, 2011 12:03 am

Greetings,

I have in windows that I have been porting to MAC OS-X 10.6.5 (utilizing the older 32-bit carbon built libraries compiled off of 2.9.1).

It connects to a server running on the localhost. There is code to handle when the server is not running, as shown below. This works as expected on windows. Until the TCP/IP server is started on the desired port, #42010, the Connect call fails, and returns false, and the loop sleeps a little bit.

But on MAC OS-X, this is not the case. Instead, after the second time in the loop, the connection is successful, and it returns true -- even though there is no server program running! I tried different port numbers and still get the same result. I'm looking for advice how to configure the client connection properly for MAC OS X.

thanks to anyone in advance!

t

code below:

wxIPV4address addr;
addr.LocalHost(); // defaults to localhost

// Note: I also tried:
// addr.AnyAddress();

// portnum = 42010, I also tried other port #...
addr.Service(m_serverPortnum);

while ( !TestDestroy() )
{

if ( m_client.IsConnected() )
m_connected = true;
else
{
// this always works with windows: returns false until
// the server is running. On MAC OS X it actually can,
// and does, return true even when there is no server
// running!!
if ( !m_client.Connect( addr ) )
{
m_connected = false;
}
else
{
m_connected = true;
}
}

if ( ! m_connected )
{
wxMilliSleep(250);
continue;
}
else
{
// do I/O and processing stuff ....
}
} // while.

Post Reply