Tcp4u - Main Index


TCP4U API - User Manual

License


Tcp4u was written by Philippe Jounin and Laurent Le Bras and is Copyrighted 1996-1998 by them.
This library is free software; you can redistribute it and/or modify it under the terms the GNU Library General Public License as published by the Free Software Foundation; either version 2, or (at your option) any later version.
This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public License for more details.
You should have received a copy of the GNU Library General Public License along with this library; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.


Overview


Tcp4u provides portable APIs which allow an easy use of the following IETF protocols :

The package contains full source code (library and samples). The DLLs and some static libraries for Windows are provided already compiled.


What's new in version 3.31 ?



What's new in version 3.30 ?



Portability


The Tcp4u functions have been compiled and tested under the following operating system:


Availability


Tcp4u is available at the following sites :

Updates, add-ons and development news are available from my home page :

Report Problem


Since Tcp4u is freeware, it has no official support. However, i try to help you as best as i can. Thus if you have some problem, please send your comments to Philippe Jounin.
If you find errors in the documentation, please be lenient: First i am French, furthermore i do not like write docs files (but who does?). Send me the corrected text, i will update this documentation for the next release.


Programming with the Tcp4u API

The package


If you intend to use Tcp4u under Unix, you have to compile the library. Please refer to the file Unix/INSTALL. Then you should have the following files :

If you intend to use Tcp4u under Windows; the DLLs and static library for MSVC are provided. The following files are necessary :

The types


Since Tcp4u was originally written for Windows, its uses Windows types. Their definitions are given in the file tcp4u.h. The most widely used are:

SOCKET
a 16 bit-unsigned integer
LPSTR
a pointer to a variable memory location
LPCSTR
a pointer to a non-writeable memory location
far
This attribute is only meaningful for Windows 3.1.

The flow of functions


The first function that an application should call is Tcp4uInit. It allocates buffers and get some information about the task which has called it. The task is ready to open connections.
The application can now establish connections with a remote server with TcpConnect (client) or wait for an incoming connection with both TcpGetListenSocket and TcpAccept. It can either use any HTTP functions.
Before quitting, the application must close opened sockets with TcpClose, and call Tcp4uCleanup.


The Tcp4u functions


This table lists alphabetically all the functions implemented in this version. The remainder
of the documentation describes them one by one.

Multi-purpose functions


Tcp4uCleanup
Last function to be called, frees local resources
Tcp4uEnableLog
Allows tracing of received/sent frames and functions
Tcp4uInit
First function to be called
Tcp4uVer
Gives the 2-part version of the library (packed into an int).
TcpGetLocalID
Returns name and address of the local host

TCP related functions


Tcp4uErrorString
Returns error string about an error code
TcpAbort
Aborts the current blocking call
TcpAccept
Waits for a incoming connection
TcpClose
Closes a socket
TcpConnect
Establishes a connection to a peer
TcpFlush
Flushes the buffer associated with a socket
TcpGetListenSocket
Creates a socket and listen for incoming connection
TcpGetRemoteID
Returns name and address of the connected host
TcpIsDataAvail
Returns TRUE if unread data are available
TcpIsOOBDataAvail
Returns TRUE if unread Out of Band data are available
TcpPPRecv
Receives data with length of frame in the two first bytes
TcpPPSend
Sends data, the two first bytes of the frame are its length
TcpRecv
Receives data
TcpRecvUntilStr
Receives data until a given character/string
TcpSend
Sends data to connected host

Telnet Related functions


TnGetAnswerCode
Receives data until end of a Telnet frame
TnProtoExchange
Completes a full telnet dialog
TnReadLine
Receives data until an end of line (10 ASCII)
TnReadMultiLine
Receives a full Tenet frame
TnSend
Sends a 0-terminated string
TnSendMultiLine
Sends a 0-terminated string. Handles end of line

HTTP related functions


Http4uErrorString
Returns an error string about a HTTP return code
Http4uSetBufferSize
Changes the internal buffer size
Http4uSetTimeout
Changes the internal timeout
HttpGetFile
Retrieves a file using the HTTP protocol
HttpGetFileEx
Retrieves both files and headers using the HTTP protocol

UDP related functions


Udp4uServiceToPort
Translates a service into a port identifier
UdpBind
Forces a socket to communicate only with a given host
UdpCleanup
Destroys the local UDP socket
UdpInit
Creates a local UDP socket
UdpSend
sends a datagram to a previously given host
UdpRecv
Receives or wait for a datagram

SMTP related functions


SmtpSendMessage
Sends a text string using the SMTP protocol.



Overview Multi purpose func. TCP functions Telnet related func HTTP functions UDP functions SMTP functions
Tcp4u version 3.31 by Ph. Jounin and Laurent Le Bras Last updated: 10th march 1998