*** empty log message ***

This commit is contained in:
David Rose 2000-10-26 18:05:15 +00:00
parent fb77b2f1f6
commit b0c66c8dd7
10 changed files with 53 additions and 22 deletions

View File

@ -54,7 +54,7 @@ process_incoming_data(SocketInfo *sinfo) {
} else {
NetAddress net_addr(addr);
net_cat.info()
<< "Received TCP connection from client " << net_addr.get_ip()
<< "Received TCP connection from client " << net_addr.get_ip_string()
<< " on port " << sinfo->_connection->get_address().get_port()
<< "\n";

View File

@ -164,13 +164,13 @@ open_TCP_client_connection(const NetAddress &address, int timeout_ms) {
}
net_cat.info()
<< "Unable to open TCP connection to server "
<< address.get_ip() << " on port " << address.get_port() << "\n";
<< address.get_ip_string() << " on port " << address.get_port() << "\n";
PR_Close(socket);
return PT(Connection)();
}
net_cat.info()
<< "Opened TCP connection to server " << address.get_ip() << " "
<< "Opened TCP connection to server " << address.get_ip_string() << " "
<< " on port " << address.get_port() << "\n";
PT(Connection) connection = new Connection(this, socket);

View File

@ -126,13 +126,13 @@ set_port(int port) {
}
////////////////////////////////////////////////////////////////////
// Function: NetAddress::get_ip
// Function: NetAddress::get_ip_string
// Access: Public
// Description: Returns the IP address to which this address refers,
// formatted as a string.
////////////////////////////////////////////////////////////////////
string NetAddress::
get_ip() const {
get_ip_string() const {
static const int buf_len = 1024;
char buf[buf_len];
@ -146,6 +146,32 @@ get_ip() const {
return string(buf);
}
////////////////////////////////////////////////////////////////////
// Function: NetAddress::get_ip
// Access: Public
// Description: Returns the IP address to which this address refers,
// as a 32-bit integer, in host byte order.
////////////////////////////////////////////////////////////////////
PN_uint32 NetAddress::
get_ip() const {
return PR_ntohl(_addr.inet.ip);
}
////////////////////////////////////////////////////////////////////
// Function: NetAddress::get_ip_component
// Access: Public
// Description: Returns the nth 8-bit component of the IP address.
// An IP address has four components; component 0 is the
// first (leftmost), and component 3 is the last
// (rightmost) in the dotted number convention.
////////////////////////////////////////////////////////////////////
PN_uint8 NetAddress::
get_ip_component(int n) const {
nassertr(n >= 0 && n < 4, 0);
const PN_uint8 *ip = (const PN_uint8 *)&_addr.inet.ip;
return ip[n];
}
////////////////////////////////////////////////////////////////////
// Function: NetAddress::get_addr
@ -164,5 +190,5 @@ get_addr() const {
////////////////////////////////////////////////////////////////////
void NetAddress::
output(ostream &out) const {
out << get_ip();
out << get_ip_string();
}

View File

@ -7,6 +7,7 @@
#define NETADDRESS_H
#include <pandabase.h>
#include <numeric_types.h>
#include <prio.h>
@ -28,7 +29,9 @@ public:
int get_port() const;
void set_port(int port);
string get_ip() const;
string get_ip_string() const;
PN_uint32 get_ip() const;
PN_uint8 get_ip_component(int n) const;
PRNetAddr *get_addr() const;

View File

@ -70,7 +70,7 @@ main(int argc, char *argv[]) {
PT(Connection) connection;
if (cm.get_reset_connection(connection)) {
nout << "Lost connection from "
<< connection->get_address().get_ip() << "\n";
<< connection->get_address() << "\n";
cm.close_connection(connection);
if (connection == c) {
lost_connection = true;

View File

@ -63,7 +63,7 @@ main(int argc, char *argv[]) {
NetAddress address;
PT(Connection) new_connection;
if (listener.get_new_connection(rv, address, new_connection)) {
nout << "Got connection from " << address.get_ip() << "\n";
nout << "Got connection from " << address << "\n";
reader.add_connection(new_connection);
clients.insert(new_connection);
}
@ -74,7 +74,7 @@ main(int argc, char *argv[]) {
PT(Connection) connection;
if (cm.get_reset_connection(connection)) {
nout << "Lost connection from "
<< connection->get_address().get_ip() << "\n";
<< connection->get_address() << "\n";
clients.erase(connection);
cm.close_connection(connection);
}

View File

@ -35,8 +35,10 @@ main(int argc, char *argv[]) {
exit(1);
}
nout << "Successfully opened TCP connection to " << hostname
<< " on port " << port << "\n";
nout << "Successfully opened TCP connection to " << hostname
<< " on port "
<< c->get_address().get_port() << " and IP "
<< c->get_address() << "\n";
QueuedConnectionReader reader(&cm, 0);
reader.add_connection(c);
@ -57,7 +59,7 @@ main(int argc, char *argv[]) {
PT(Connection) connection;
if (cm.get_reset_connection(connection)) {
nout << "Lost connection from "
<< connection->get_address().get_ip() << "\n";
<< connection->get_address() << "\n";
cm.close_connection(connection);
if (connection == c) {
lost_connection = true;
@ -69,7 +71,7 @@ main(int argc, char *argv[]) {
while (reader.data_available()) {
if (reader.get_data(datagram)) {
nout << "Got datagram " << datagram << "from "
<< datagram.get_address().get_ip() << "\n";
<< datagram.get_address() << "\n";
}
}

View File

@ -53,7 +53,7 @@ main(int argc, char *argv[]) {
NetAddress address;
PT(Connection) new_connection;
if (listener.get_new_connection(rv, address, new_connection)) {
nout << "Got connection from " << address.get_ip() << "\n";
nout << "Got connection from " << address << "\n";
reader.add_connection(new_connection);
clients.insert(new_connection);
}
@ -64,7 +64,7 @@ main(int argc, char *argv[]) {
PT(Connection) connection;
if (cm.get_reset_connection(connection)) {
nout << "Lost connection from "
<< connection->get_address().get_ip() << "\n";
<< connection->get_address() << "\n";
clients.erase(connection);
cm.close_connection(connection);
}
@ -75,7 +75,7 @@ main(int argc, char *argv[]) {
NetDatagram datagram;
if (reader.get_data(datagram)) {
nout << "Got datagram " << datagram << "from "
<< datagram.get_address().get_ip() << ", sending to "
<< datagram.get_address() << ", sending to "
<< clients.size() << " clients.\n";
Clients::iterator ci;
@ -91,7 +91,7 @@ main(int argc, char *argv[]) {
nout << "Empty datagram from a null connection.\n";
} else {
nout << "Closing connection from "
<< connection->get_address().get_ip() << "\n";
<< connection->get_address() << "\n";
clients.erase(connection);
cm.close_connection(connection);
nout << "Closed " << connection << "\n";

View File

@ -37,7 +37,7 @@ main(int argc, char *argv[]) {
nout << "Successfully opened UDP connection on port "
<< c->get_address().get_port() << " and IP "
<< c->get_address().get_ip() << "\n";
<< c->get_address() << "\n";
RecentConnectionReader reader(&cm);
reader.add_connection(c);
@ -58,7 +58,7 @@ main(int argc, char *argv[]) {
PT(Connection) connection;
if (cm.get_reset_connection(connection)) {
nout << "Lost connection from "
<< connection->get_address().get_ip() << "\n";
<< connection->get_address() << "\n";
cm.close_connection(connection);
if (connection == c) {
lost_connection = true;
@ -70,7 +70,7 @@ main(int argc, char *argv[]) {
while (reader.data_available()) {
if (reader.get_data(datagram)) {
nout << "Got datagram " << datagram << "from "
<< datagram.get_address().get_ip() << "\n";
<< datagram.get_address() << "\n";
}
}

View File

@ -35,7 +35,7 @@ connection_opened(const PT(Connection) &,
return;
}
nout << "Got new connection from " << address.get_ip() << "\n";
nout << "Got new connection from " << address << "\n";
PStatReader *reader = new PStatReader(_manager, monitor);
_manager->add_reader(new_connection, reader);