www.pudn.com > CTP.zip > NetBasic.cpp


// IPAddr represents workstations network address 
// NetSender - Interface for network sending provider 
// NetReceiver - Interface for network receiving provider 
// Implementation file 
// 
// (c) Lev Naumov, CAMEL Laboratory 
// E-mail: camellab@mail.ru 
// For more information see http://camel.ifmo.ru or 
// http://www.codeproject.com/internet/ctp.asp 
///////////////////////////////////////////////////////////////////////////// 
 
#include "stdafx.h" 
 
#include "NetBasic.h" 
 
bool IPAddr::FromString(LPTSTR s) 
{ 
    Bytes.b1=(unsigned char)atoi(s); 
    s=strchr(s,'.'); 
    if (!s) {SetLocalhost(); return false;} 
    s++; 
    Bytes.b2=(unsigned char)atoi(s); 
    s=strchr(s,'.'); 
    if (!s) {SetLocalhost(); return false;} 
    s++; 
    Bytes.b3=(unsigned char)atoi(s); 
    s=strchr(s,'.'); 
    if (!s) {SetLocalhost(); return false;} 
    s++; 
    Bytes.b4=(unsigned char)atoi(s); 
    return true; 
}