TCPADDR for PB/DLL & PB/CC 
Author Message
 TCPADDR for PB/DLL & PB/CC

This code will return the IP address used to make a TCP/IP connection.  This
is especially useful if your computer has more than one IP address (one for
the network and one for a dialup connection, as an example).

Once you've made a connection to a server you can call this to find out
which IP address was used to make the connection.

Unfortunately, it doesn't tunnel through proxies.  If you use a proxy server
or a cable/dsl router it will return the IP address for your local network
connection, not the IP address used by your router to access the Internet.

UNION in_addr
  s_addr AS LONG
  s AS STRING * 4
END UNION

TYPE sockaddr_in
  sin_family AS WORD
  sin_port AS WORD
  sin_addr AS in_addr
  sin_zero AS STRING * 8
END TYPE

DECLARE FUNCTION getsockname LIB "wsock32.dll" ALIAS "getsockname" (BYVAL s
AS LONG, sname AS sockaddr_in, namelen AS LONG) AS LONG

FUNCTION TcpAddr(BYVAL s AS LONG) AS LONG

  LOCAL sa AS sockaddr_in
  LOCAL l  AS LONG

  s = FILEATTR(s,2) ' get socket handle
  l = SIZEOF(sa)

  IF getsockname(s, sa, l) = 0 THEN
    FUNCTION = sa.sin_addr.s_addr
  END IF

END FUNCTION

--Dave



Sun, 01 Feb 2004 01:21:41 GMT  
 
 [ 1 post ] 

 Relevant Pages 

1. MX Lookup with PB/CC or PB/DLL

2. Info on new PB/CC and PB/DLL

3. Announcing the JazzAge COM Wizard for PB/DLL and PB/CC

4. animated characters, speech input/output in PB/DLL and PB/CC

5. email enable PB/DLL-PB/CC using Outlook

6. SQL, ADO/OLE-DB programming in PB/DLL and PB/CC

7. add support for COM and OCXs to PB/DLL-CC

8. add COM components and OCXs support to PB/DLL-CC

9. PB/cc & code pages

10. PB 3.2.PB/Vision 2.0 Timerinstallcode.Shared Arrays

11. new JA 'CE' for PB/DLL, PB/CC OpenBeta3

12. NUL device not working in PB/CC?

 

 
Powered by phpBB® Forum Software