15 мая 2023 года "Исходники.РУ" отмечают своё 23-летие!
Поздравляем всех причастных и неравнодушных с этим событием!
И огромное спасибо всем, кто был и остаётся с нами все эти годы!

Главная Форум Журнал Wiki DRKB Discuz!ML Помощь проекту


CSocket programming dilemna

Jason R. Simpson -- doecreek@tir.com
Tuesday, August 13, 1996

Env:  MSVC 1.52c, Windows 95, WFW311, NT351

Earlier I had posted an article concerning two applications using =
CSocket derived classes for communication.  The problem was that the =
applications would not run under WFW311 or NT351 but it ran without =
fault under Win95.

I resolved the issue and thought that it wouldn't hurt to post the =
information.  Both the client and server application were running on the =
same machine with the ip address 4.3.2.20.  The netstat command informed =
me that my client application was trying to connect to 4.3.2.16.  =
Internally, in CAsyncSocket::Connect() where the SOCKADDR_IN structure =
is filled in with the appropriate values before the Winsock API =
connect() function is called, inet_addr() is used to convert the ip =
address from the decimal delimited string to the appropriate format.  =
Well, if I have a string containing the value 004.003.002.020, =
inet_addr() stores it as 4.3.2.16, but if I have a string containing the =
value 4.3.2.20, inet_addr() stores it correctly. =20

This preplexes me and if anyone has any information on this situation, I =
would like to hear about it.  Either way, my problem is resolved, I just =
do not understand the logic of it.

Jason Simpson
TimeTrak Systems, Inc
Port Huron, MI




Rickard Lind -- rickard.lind@st.se
Thursday, August 15, 1996

[Moderator's note: There were 20 responses, all basically the same.]

>Env:  MSVC 1.52c, Windows 95, WFW311, NT351
[snip]
>decimal delimited string to the appropriate format.  Well, if I have a
string containing the value
>004.003.002.020, inet_addr() stores it as 4.3.2.16, but if I have a string
containing the value
>4.3.2.20, inet_addr() stores it correctly.  
>
>This preplexes me and if anyone has any information on this situation, I
would like to hear about it.
>Either way, my problem is resolved, I just do not understand the logic of it.

In C/C++, a number with a leading zero is usually interpreted as an octal
(base 8) number, just as a
leading 0x indicates hexadecimal (base 16). Octal 20 == decimal 16.

>Jason Simpson
>TimeTrak Systems, Inc
>Port Huron, MI

/r
____________________________________________________________
 Rickard Lind                     mailto:rickard.lind@st.se
 S&T Datakonsulter                         http://www.st.se
 Valhallav. 191                         voice:+46 8 7832714
 Box 27183                                fax:+46 8 6678230
 104 51 Stockholm                       cell:+46 708 432484





| Вернуться в корень Архива |