Retro video games delivered to your door every month!
Click above to get retro games delivered to your door ever month!
X-Hacker.org- Novlib 3.30 Online Reference - <b> spxconnect()</b> http://www.X-Hacker.org [<<Previous Entry] [^^Up^^] [Next Entry>>] [Menu] [About The Guide]
 SPXConnect()
------------------------------------------------------------------------------
 Purpose:
 Establish an SPX connection with another workstation.

 Syntax:
 dwConnNum = SPXConnect(lpszAddress, wSocket ,wTime)

 Parameters:
 lpszAddress The full network address of the workstation with which to
             connect, comprising the network number, the node number and
             thesocket number.
 wSocket     The local socket number to use.
 wTime       The period of time to wait for a connection.

 Returns:
 A numeric value (unsigned long int).

 The CA-Clipper name for this function is:
 SPXConnect()

 Description:
 SPXConnect() attempts to establish an SPX connection with the workstation
 whose network address is specified by lpszAddress. If lpszAddress is
 passed as an empty (NULL) string SPXConnect(), waits for up to wTime
 seconds for another workstation to connect with it.

 The network address is the physical address of the workstation with which
 to connect. The network address is a 24 character string. The first 8 bytes
 represent the address of the network segment, the next 12 bytes the
 physical address of the workstation and the last 4 bytes the socket number.
 For example address "0000000208001BC657734545" is made up of the network
 segment "00000002", the workstation address "08001BC65773" and the socket
 number "4545". All these figures are in hexadecimal.
 To find the network segment address and workstation address of a particular
 user, use functions WSNetAddressGet() and WSNodeAddressGet(). The socket
 number wSocket is the SPX socket number which will be used for the
 connection. If the constant value NOVDEFINT is passed for this parameter,
 the socket number defaults to 17733 ( 0x4545 ) + the number of current SPX
 connections.

 SPXConnect() can only connect to another workstation that is listening for
 a connection attempt. If lpszAddress is passed as an empty (NULL) string,
 SPXConnect() will listen for another workstation attempting to connect with
 it. SPXConnect() will wait up to wTime seconds. If no connection is
 established by the time this period has elapsed an error is returned. If
 successful, SPXConnect() returns a NOVLIB SPX connection number or
 NOVERRLONG if an error has occurred.

 Example:
 // To attempt to connect to user KATIE as an SPX partner:
 lpszPacket = str( recno() )
 if UsrConnList( "KATIE" ) > 0
    iConnNo = UsrConnList("" )
    lpszAddress =  WSNetAddressGet(iConnNo)
                + WSNodeAddressGet(iConnNo)
                + "4545"
    if( ( dwSPXConn = SPXConnect( lpszAddress, NOVDEFINT, 30 ) ) > 0 )
       ? "Connected to user KATIE, SPX connection No.", dwSPXConn
    else
       ? "User KATIE is not listening"
    endif
 else
    ? "User KATIE is not logged in"
 endifTo listen for 30 seconds to see if anyone wants to connect with us:if(
 (dwSPXConn = SPXConnect( "", 0, 30 )) > 0 )
    ? "Workstation ",SPXAddressGet(dwSPXConn)," has connected "
    ?? "with us on connection number ",dwSPXConn
 else
    ? "No one is trying to connect with us."
 endif

 Notes:
 It is recommended not to change the default socket number "4545" (
 17733 ) unless you find you are clashing with a socket opened by another
 process.

See Also: SPXInstalled() SPXPacketGet() SPXPacketSend() WSNetAddressGet() WSNodeAddressGet()

Online resources provided by: http://www.X-Hacker.org --- NG 2 HTML conversion by Dave Pearson