Sprezzatura's S/Ocket is a 32-bit DLL that enables a developer to include basic TCP/IP communications to a server from their 32-bit OpenInsight application/s and ARev and OI16-bit applications using an OI32 runtime. Whereas the socket functionality in OpenInsight 7.1 is designed to handle high-level protocols such as FTP and HTTP, S/ocket is designed to provide more flexibility to the developer by allowing 'raw' data streams to be sent and received, thus granting the ability to implement custom and extended TCP protocol programming. There are 8 functions that have been prototyped in OpenInsight and each is highlighted below to give you an idea of what can be achieved using S/Ocket. Definitions This function makes a connection to a server on a specified port and must be called before any further communications with the server can take place. retVal = zzx_TCPConnect( lpDestination, lpPort ) Arguments
Returns If the function is successful a handle to the connection is returned (this must be used in subsequent communications with the server). If the function fails for any reason then 0 is returned. Example declare function zzx_TCPConnect lpDest = 'www.sprezzatura.com' : \00\ hSocket = zzx_TCPConnect( lpDest, iPort )
This subroutine is used to close the connection to a server previously opened with the zzx_TCPConnect() function. call zzx_TCPClose( hSocket ) Arguments:
Returns N/A Example declare function zzx_TCPConnect lpDest = 'www.sprezzatura.com' : \00\ hSocket = zzx_TCPConnect( lpDest, iPort ) if hSocket then end
This function is used to send data to a server. retVal = zzx_TCPWrite( hSocket, lpBuffer, iBufferLen ) Arguments:
Returns Returns 1 if successful, 0 otherwise. Example declare function zzx_TCPConnect, zzx_TCPWrite lpDest = 'www.sprezzatura.com' : \00\ hSocket = zzx_TCPConnect( lpDest, iPort ) if hSocket then retVal = zzx_TCPWrite( hSocket, lpBuffer, iBufferLen ) * // More processing .... call zzx_TCPClose( hSocket ) end
This function is used to send data to a server but an EOL string is appended to the data before it is sent (ie... Char(13) and Char(10)) retVal = zzx_TCPWriteLn( hSocket, lpBuffer, iBufferLen ) Arguments:
Returns Returns 1 if successful, 0 otherwise. Example declare function zzx_TCPConnect, zzx_TCPWriteLn lpDest = 'www.sprezzatura.com' : \00\ hSocket = zzx_TCPConnect( lpDest, iPort ) if hSocket then retVal = zzx_TCPWriteLn( hSocket, lpBuffer, iBufferLen ) * // More processing .... call zzx_TCPClose( hSocket ) end
This function is used to read data from a server. retVal = zzx_TCPRead( hSocket, lpBuffer, iBufferLen ) Arguments:
Returns Returns 1 if successful, 0 otherwise. Example declare function zzx_TCPConnect, zzx_TCPWrite, zzx_TCPRead lpDest = 'www.sprezzatura.com' : \00\ hSocket = zzx_TCPConnect( lpDest, iPort ) if hSocket then retVal = zzx_TCPWrite( hSocket, lpBuffer, iBufferLen ) if retVal then retVal = zzx_TCPRead( hSocket, lpBuffer, iBufferLen ) end call zzx_TCPClose( hSocket ) end
This function is used to read a line of data from a server. By default lines are delimited by Char(10) but it is possible to specify a different delimiter. retVal = zzx_TCPReadLn( hSocket, lpBuffer, iBufferLen, lpDelim ) Arguments:
Returns Returns 1 if successful, 0 otherwise. Example declare function zzx_TCPConnect, zzx_TCPWrite, zzx_TCPReadLn lpDest = 'www.sprezzatura.com' : \00\ hSocket = zzx_TCPConnect( lpDest, iPort ) if hSocket then retVal = zzx_TCPWrite( hSocket, lpBuffer, iBufferLen ) if retVal then retVal = zzx_TCPReadLn( hSocket, lpBuffer, iBufferLen, lpDelim ) end call zzx_TCPClose( hSocket ) end
This function is used to read data from a server. retVal = zzx_TCPReadEx( hSocket, lpBuffer, iBufferLen, Arguments:
Returns Returns 1 if successful, 0 otherwise. Example declare function zzx_TCPConnect, zzx_TCPWrite, zzx_TCPReadEx lpDest = 'www.sprezzatura.com' : \00\ hSocket = zzx_TCPConnect( lpDest, iPort ) if hSocket then retVal = zzx_TCPWrite( hSocket, lpBuffer, iBufferLen ) if retVal then retVal = zzx_TCPReadEx( hSocket, lpBuffer, iBufferLen, end call zzx_TCPClose( hSocket ) end
This function is used to read a line of data from a server. By default lines are delimited by Char(10) but it is possible to specify a different delimiter. retVal = zzx_TCPReadLn( hSocket, lpBuffer, iBufferLen, lpDelim ) Arguments:
Returns Returns 1 if successful, 0 otherwise. Example declare function zzx_TCPConnect, zzx_TCPWrite, zzx_TCPReadLnEx lpDest = 'www.sprezzatura.com' : \00\ hSocket = zzx_TCPConnect( lpDest, iPort ) if hSocket then retVal = zzx_TCPWrite( hSocket, lpBuffer, iBufferLen ) if retVal then retVal = zzx_TCPReadLnEx( hSocket, lpBuffer, iBufferLen, lpDelim, end call zzx_TCPClose( hSocket ) end
|
| Copyright © 2005 The Sprezzatura Group. All rights reserved. |