Correct path MTU discovery

This commit is contained in:
Keith Winstein
2011-08-03 21:35:48 -04:00
parent 7ea81ca237
commit b84599f263
2 changed files with 12 additions and 6 deletions
+11 -5
View File
@@ -130,19 +130,25 @@ void Connection<Outgoing, Incoming>::client_connect( const char *ip, int port )
} }
template <class Outgoing, class Incoming> template <class Outgoing, class Incoming>
void Connection<Outgoing, Incoming>::send( Outgoing &s ) bool Connection<Outgoing, Incoming>::send( Outgoing &s )
{ {
assert( attached ); assert( attached );
string p = flow.new_packet( s ).tostring(); string p = flow.new_packet( s ).tostring();
if ( sendto( sock, p.data(), p.size(), 0, ssize_t bytes_sent = sendto( sock, p.data(), p.size(), 0,
(sockaddr *)&remote_addr, sizeof( remote_addr ) ) < 0 ) { (sockaddr *)&remote_addr, sizeof( remote_addr ) );
if ( (bytes_sent < 0) && (errno == EMSGSIZE) ) {
update_MTU();
return false;
} else if ( bytes_sent == static_cast<int>( p.size() ) ) {
return true;
} else {
perror( "sendto" ); perror( "sendto" );
exit( 1 ); exit( 1 );
return false;
} }
update_MTU();
} }
template <class Outgoing, class Incoming> template <class Outgoing, class Incoming>
+1 -1
View File
@@ -78,7 +78,7 @@ namespace Network {
Connection( bool s_server ); Connection( bool s_server );
void client_connect( const char *ip, int port ); void client_connect( const char *ip, int port );
void send( Outgoing &s ); bool send( Outgoing &s );
Incoming recv( void ); Incoming recv( void );
int fd( void ) { return sock; } int fd( void ) { return sock; }
int port( void ); int port( void );