X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Fport.cpp;fp=source%2Fport.cpp;h=11ccfe0331674ebe05a1fc37a332c7216e7e02aa;hb=c147c9caaf9bc2f6323baf188a438ced9f0f5894;hp=0000000000000000000000000000000000000000;hpb=6ffe2b950143c5474659cbca2bbcdf58d6b8322c;p=netvis.git diff --git a/source/port.cpp b/source/port.cpp new file mode 100644 index 0000000..11ccfe0 --- /dev/null +++ b/source/port.cpp @@ -0,0 +1,27 @@ +/* $Id$ + +This file is part of NetVis +Copyright @ 2008 Mikko Rasa, Mikkosoft Productions +Distributed unter the GPL +*/ + +#include +#include +#include +#include "port.h" + +Port::Port(unsigned n, const Msp::GL::Color &c): + number(n), + color(c) +{ + char buf[128]; + sockaddr_in addr; + addr.sin_family = AF_INET; + addr.sin_port = ntohs(number); + addr.sin_addr.s_addr = 0; + int err = getnameinfo(reinterpret_cast(&addr), sizeof(sockaddr_in), 0, 0, buf, sizeof(buf), 0); + if(err==0) + name = buf; + else + name = Msp::lexical_cast(number); +}