1
Network / Failed to bind the socket to port 5200?
« on: June 10, 2009, 01:38:41 am »
Ich have the solution...
This works:
Declaring the Socket as local Variable works - I think the Stack gets corrupted before CNetTest::Receive() is called.
This works:
Code: [Select]
void Receive()
{
if ( !GetClientInfo() ) { return; };
if ( !SendClientInfo() ) { return; };
sf::SocketUDP m_ClientUDP;
bool bValid = 0;
int ErrorVal = 0;
sf::IPAddress Address;
unsigned short Port = 5200;
bValid = m_ClientUDP.IsValid();
m_ClientUDP.Unbind();
bValid = m_ClientUDP.Bind( Port );
ErrorVal = WSAGetLastError();
std::cout << "WSAGetLastError: " << ErrorVal << std::endl;
while (1)
{
sf::Packet DataPacket;
if (m_ClientUDP.Receive(DataPacket, Address, Port) != sf::Socket::Done)
{
return;
}
std::cout << "Got Data: " << DataPacket.GetDataSize() << " Bytes" << std::endl;
sf::Sleep( m_Ping );
}
};
Declaring the Socket as local Variable works - I think the Stack gets corrupted before CNetTest::Receive() is called.