Make SetLocal actually work instead of crashing immediately; due to required longevity of the item to make it from SetLocal to Connect, we need to use a specifc address type.

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@37759 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Kevin Hock
2006-02-28 02:04:29 +00:00
parent fb3234e549
commit 30bbf68d3a
3 changed files with 12 additions and 4 deletions

View File

@@ -1203,13 +1203,14 @@ bool wxSocketBase::SetOption(int level, int optname, const void *optval,
return true;
}
bool wxSocketBase::SetLocal(wxSockAddress& local)
bool wxSocketBase::SetLocal(wxIPV4address& local)
{
GAddress* la = local.GetAddress();
// If the address is valid, save it for use when we call Connect
if (la && la->m_addr)
{
m_socket->SetLocal(la);
m_localAddress = local;
return true;
}
@@ -1274,6 +1275,12 @@ bool wxSocketClient::DoConnect(wxSockAddress& addr_man, wxSockAddress* local, bo
m_socket->SetReusable();
}
// If no local address was passed and one has been set, use the one that was Set
if (!local && m_localAddress.GetAddress())
{
local = &m_localAddress;
}
// Bind to the local IP address and port, when provided
if (local)
{