On 03-Nov-99 Martin van Velsen wrote:
> Pose/Emulator does not seem to be able to retrieve the network info
> from windows95/98 ( on a PPP connection ) ...
Hi. FWIW you can use the NetLibSocketAddr() to get both the local and remote
IP of an active socket. The trick is that the local IP will only be returned
if the socket is currently connected; i.e. after a successful
NetLibSocketConnect(). I just tried it under POSE and it does return the IP
of the Windows95 machine.
NetSocketAddrType laddr, raddr;
SWord laddrlen, raddrlen;
laddrlen = sizeof(laddr);
raddrlen = sizeof(raddr);
if ((NetLibSocketAddr(AppNetRefnum, sock, &laddr, &laddrlen,
&raddr, &raddrlen, AppNetTimeout, &errno)) == 0) {
/*
* Trying to avoid a bus error which I presume would happen if
* I tried to typecast.
*/
inetval = ((DWord) laddr.data[5]) + (((DWord) laddr.data[4])<<8) +
(((DWord) laddr.data[3])<<16) + (((DWord) laddr.data[2])<<24);
NetLibAddrINToA(AppNetRefnum, inetval, localip);
inetval = ((DWord) raddr.data[5]) + (((DWord) raddr.data[4])<<8) +
(((DWord) raddr.data[3])<<16) + (((DWord) raddr.data[2])<<24);
NetLibAddrINToA(AppNetRefnum, inetval, remoteip);
} else {
NetLibSocketClose(AppNetRefnum, sock, AppNetTimeout, &errno);
localip[0] = (char) NULL;
remoteip[0] = (char) NULL;
ShowInfoMsg("");
SetErrorMsg("NetLibSocketAddr failure.");
return 0;
}
StrCopy(tempbuf, "Connected to ");
StrCat(tempbuf, remoteip);
ShowInfoMsg(tempbuf);
/* Chris Faherty <[EMAIL PROTECTED]>, finger for PGP */