Class wwSocket

The wwSocket class is a basic client side TCP/IP access library that lets you read and write raw sockets with a few simple method calls. Note only TCP/IP is supported - no UTP support.



Based on: Custom
Stored in: wwIPStuff.vcx


Remarks

IMPORTANT: You can only run one socket instance per FoxPro application!!! If you connect a second socket you will kill any previous existing socket connections created with this class.

Requires Winsock 2.0 on the client machine. (ws2_32.dll in your SYSTEM32/SYSTEM dir).

Class Members

MemberDescription

connect

Connects to a socket on a server.

o.connect(lcServer, lnPort)

disconnect

Disconnects from a socket on the server.

o.disconnect()

GetLog

Returns the content of the log captured when lLogSession is .T.

o.GetLog()

Listen

Puts a socket into server mode to listen for incoming connections on a given port. If a connection is made the socket is opened for reading and writing using the regular Send/Receive etc. methods.

o.Listen(lnPort,lnTimeOut)

receive

Receives data from a socket.

o.receive(lnSize)

send

Sends data to a socket on the server.

o.send(lcInput)

sendreceive

Sends a string to the open socket, waits for a response and returns the string response.

o.sendreceive(lcInput,lnSize)

socketsend

High level method that connects to a socket, sends data and receives a result then disconnects from the socket. Great for various XML services that follow a simple transaction model with a 'hit'.

o.socketsend(lcInput,lcServer,lnServerPort,lnTimeout,@lcError)

WaitFor

Receives data until either the provided string is found or the request times out based on the nTimeout property setting.

o.WaitFor(lcSearchString,lnSize)

WaitForSize

Reads a socket until the specified number of bytes are received.

o.WaitForSize(lnBytes)

cerrormsg

Error Message if an error occurred.

lLogSession

Allows you to log the entire TCP/IP session and retrieve the log via the GetLog() method.

lstripnulls

Strips CHR(0) NULLS from the received buffer. Otherwise the full buffer will be passed back which is padded with CHR(0)'s.

nBufferSize

The default Receive buffer size in bytes. This size is used to determine how much data the socket waits for at a time before returning control to you.

nerror

Error Number

nLastReadSize

The size of the data returned on the last Receive() method call. Use this if you're reading binary data that might contain NULLS and might not fill the buffer fully.

ntimeout

Socket timeout, in seconds, used to determine when an operation fails due to an idle timeout of no data sent or received.


© West Wind Technologies, 1996-2024 • Updated: 05/14/13
Comment or report problem with topic