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> spxpacketget()</b> http://www.X-Hacker.org [<<Previous Entry] [^^Up^^] [Next Entry>>] [Menu] [About The Guide]
 SPXPacketGet()
------------------------------------------------------------------------------
 Purpose:
 Get a received SPX packet.

 Syntax:
 lpbyPacket = SPXPacketGet(iConnNum, lpwLength )

 Parameters:
 iConnNum   The connection number.
 lpwLength  Pointer to variable to receive the length of the received
            packet (i.e. variable passed by reference).

 Returns:
 A character string of up to length 512.

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

 Description:
 SPXPacketGet() retrieves the contents of an SPX packet received from the
 SPX connection partner specified by the connection number iConNum.

 SPXPacketGet() can only be called once an SPX session has been set up using
 SPXConnect(). The packet contents can be up to 512 bytes in length, and can
 contain anything from binary data to an ASCII message. SPXPacketGet() has
 no way of knowing that an incoming packet has been received, so must be
 continually called to check for incoming packets.

 SPXPacketGet() returns a character string containing the data contents of
 the packet, or an empty string if no packet has been received or an error
 has occurred.

 Example:
 // To listen for an SPX connection attempt and then poll for
 // received packets:
 if( dwConnNo = SPXConnect() > 0 )
    ? "Connected to workstation ",SPXAddressGet( dwConnNo )
    do while TRUE
       lpszPacket = SPXPacketGet( dwConnNo, @lpwLength )
       if empty( lpszPacket )
          nKey = inkey(1)
          if nKey != 27
             loop
          else
             ? "Connection Cancelled by user"
             exit
          endif
       else
          ? "Packet received :", lpszPacket
       endif
    enddo
    SPXDisconnect( dwConnNo )
 endif

 CA-Clipper 5.x:To listen for an incoming packet from the connection
 partner and automatically display it on the screen by calling SPXPktGet()
 from inside an event function:
 PUBLIC nConnNo
 if( nConnNo = SPXConnect() > 0 )
    SPXEvtIni( "ONSPX" )
 endif
 // program carries on normally from here, until a packet is received.
 // ONSPX() is automatically called by an incoming packet
 FUNCTION ONSPX()
    LOCAL cPacket, nlength
    nlength = 0
    if( nConnNo = SPXEvtConGet() )
       cPacket = SPXPktGet(nConno, @nlength)
       ? "Packet received :", cPacket
       ? "From connection ",nConnNo
    endif
 return NIL

 Notes:
 Note for CA-Clipper: As there can be more than 1 SPX connection,
 use SPXEvtConGet() to determine which connection caused the event.

See Also: SPXInstalled() SPXConnect() SPXPacketSend()

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