CSocket Slow? && GetHostName == 0
Poul A. Costinsky -- Poul@wizsoft.com
Thursday, July 25, 1996
Environment: VC++ 4.1 NT 3.51 & Win95
Hi here!
1. The GetHostName (and ::getsockname) returns 0.0.0.0 address
instead of real IP. How can I receive IP address of my socket?
[Moderator's note: I don't understand, Poul. Both of these are
documented as returning 0 if they succeed, and both of them are
supposed to be used to get the name, not the address. I believe
that you need to call gethostname() to get the name of your host,
and gethostbyname() to get the address of the named host.]
2. When using CSocket class (as recommended in help) my client/server
pair exchange 10 bytes in sec; the same pair written in Winsock API
exchanges 1Mb/sec. Is it some catch here?
Thanx!
Regards,
Poul.
("`-''-/").___..--''"`-._ ~~~~~~~~~~Poul A. Costinsky~~~~~~~~~~
(`6_ 6 ) `-. ( ).`-.__.`) Poul@wizsoft.com
(_Y_.)' ._ ) `._ `. ``-..-' PoulACost@msn.com
_..`--'_..-_/ /--'_.' ,'
(il).-'' (li).' ((!.- http://www.wizsoft.com/~Poul/poul.htm
Doug Boone -- dboone@fasttax.com
Sunday, July 28, 1996
When you say that you want to "receive IP address of my socket?" do you
mean who the socket is connected to or your own address?
This is a chunk of code that I use to get my own address AFTER WinSock is
initialized:
BOOL FT_WinSock::InitMyAddress(void)
{
char szName[64];
struct hostent *h;
if (!gethostname(szName,sizeof(szName)))
{
h = (struct hostent *) gethostbyname(szName);
memcpy(&m_dwMyAddress,h->h_addr_list[0],sizeof(DWORD));
if (m_dwMyAddress == INADDR_NONE)
{
m_szMyAddress[0] = ' ';
return(FALSE);
}
else
{
char *ptr;
struct in_addr tAddr;
memcpy(&tAddr,&m_dwMyAddress,sizeof(DWORD));
ptr = pinet_ntoa(tAddr);
lstrcpy(m_szMyAddress,ptr);
return(TRUE);
}
}
return(FALSE);
}
----------
> From: Poul A. Costinsky
> To: 'mfc-l'
> Subject: CSocket Slow? && GetHostName == 0
> Date: Thursday, July 25, 1996 9:20 AM
>
> Environment: VC++ 4.1 NT 3.51 & Win95
>
> Hi here!
> 1. The GetHostName (and ::getsockname) returns 0.0.0.0 address
> instead of real IP. How can I receive IP address of my socket?
>
> [Moderator's note: I don't understand, Poul. Both of these are
> documented as returning 0 if they succeed, and both of them are
> supposed to be used to get the name, not the address. I believe
> that you need to call gethostname() to get the name of your host,
> and gethostbyname() to get the address of the named host.]
>
> 2. When using CSocket class (as recommended in help) my client/server
> pair exchange 10 bytes in sec; the same pair written in Winsock API
> exchanges 1Mb/sec. Is it some catch here?
>
> Thanx!
>
> Regards,
> Poul.
> ("`-''-/").___..--''"`-._ ~~~~~~~~~~Poul A. Costinsky~~~~~~~~~~
> (`6_ 6 ) `-. ( ).`-.__.`) Poul@wizsoft.com
> (_Y_.)' ._ ) `._ `. ``-..-' PoulACost@msn.com
> _..`--'_..-_/ /--'_.' ,'
> (il).-'' (li).' ((!.- http://www.wizsoft.com/~Poul/poul.htm
>
| Вернуться в корень Архива
|