void UIpConnection::InitLocalConnection(UNetDriver* InDriver, class FSocket* InSocket, const FURL& InURL, EConnectionState InState, int32 InMaxPacket, int32 InPacketOverhead) { InitBase(InDriver, InSocket, InURL, InState, // Use the default packet size/overhead unless overridden by a child class (InMaxPacket == 0 || InMaxPacket > MAX_PACKET_SIZE) ? MAX_PACKET_SIZE : InMaxPacket, InPacketOverhead == 0 ? UDP_HEADER_SIZE : InPacketOverhead); // Figure out IP address from the host URL bool bIsValid = false; // Get numerical address directly. RemoteAddr = InDriver->GetSocketSubsystem()->CreateInternetAddr(); RemoteAddr->SetIp(*InURL.Host, bIsValid); RemoteAddr->SetPort(InURL.Port); // Try to resolve it if it failed if (bIsValid == false) { // Create thread to resolve the address. ResolveInfo = InDriver->GetSocketSubsystem()->GetHostByName(TCHAR_TO_ANSI(*InURL.Host)); if (ResolveInfo == NULL) { Close(); UE_LOG(LogNet, Verbose, TEXT("IpConnection::InitConnection: Unable to resolve %s"), *InURL.Host); } } // Initialize our send bunch InitSendBuffer(); }
void UDemoNetConnection::InitConnection( UNetDriver* InDriver, EConnectionState InState, const FURL& InURL, int32 InConnectionSpeed ) { // default implementation Super::InitConnection( InDriver, InState, InURL, InConnectionSpeed ); InitSendBuffer(); // the driver must be a DemoRecording driver (GetDriver makes assumptions to avoid Cast'ing each time) check( InDriver->IsA( UDemoNetDriver::StaticClass() ) ); }
void UDemoNetConnection::FlushNet( bool bIgnoreSimulation ) { // in playback, there is no data to send except // channel closing if an error occurs. if ( GetDriver()->ServerConnection != NULL ) { InitSendBuffer(); } else { Super::FlushNet( bIgnoreSimulation ); } }
void UIpConnection::InitRemoteConnection(UNetDriver* InDriver, class FSocket* InSocket, const FURL& InURL, const class FInternetAddr& InRemoteAddr, EConnectionState InState, int32 InMaxPacket, int32 InPacketOverhead) { InitBase(InDriver, InSocket, InURL, InState, // Use the default packet size/overhead unless overridden by a child class (InMaxPacket == 0 || InMaxPacket > MAX_PACKET_SIZE) ? MAX_PACKET_SIZE : InMaxPacket, InPacketOverhead == 0 ? UDP_HEADER_SIZE : InPacketOverhead); // Copy the remote IPAddress passed in bool bIsValid = false; FString IpAddrStr = InRemoteAddr.ToString(false); RemoteAddr = InDriver->GetSocketSubsystem()->CreateInternetAddr(); RemoteAddr->SetIp(*IpAddrStr, bIsValid); RemoteAddr->SetPort(InRemoteAddr.GetPort()); URL.Host = RemoteAddr->ToString(false); // Initialize our send bunch InitSendBuffer(); // This is for a client that needs to log in, setup ClientLoginState and ExpectedClientLoginMsgType to reflect that SetClientLoginState( EClientLoginState::LoggingIn ); SetExpectedClientLoginMsgType( NMT_Hello ); }