Česky
Kamil Dudka

Tiny programs (C, C++, C#, ...)

File detail

Name:Downloadtcp_client.h [Download]
Location: tiny > ISA > nntpbackup
Size:997 B
Last modification:2022-09-09 13:06

Source code

/*
 * file: tcp_client.h - TCP layer encapsulation
 * project: nntpbackup (ISA)
 * By Kamil Dudka, xdudka00
 * mailto: xdudka00@gmail.com
 * Note: This modul was primarily developed for project BSD sockets (IPK)
 */
 
#ifndef NET_CLIENT_H
#define NET_CLIENT_H
 
#ifdef __cplusplus
extern "C" {
#endif
	// TCP Layer ADT
	typedef int TSocket;
	typedef struct NetLine TNetLine, *PNetLine;
 
	/*
	 * Connect to server
	 * Set sockfd to connected socket
	 * return 0 if no error occur
	 */
	int netConnect (const char *serverName, unsigned portNumber, TSocket *sockfd);
 
	/*
	 * Close opened socket
	 */
	void netClose (TSocket socket);
 
	/*
	 * Initialize TCP I/O
	 */
	PNetLine netLineInit (TSocket socket, unsigned defaultLineSize);
 
	/*
	 * Destroy TCP I/O
	 */
	void netLineDestroy (PNetLine);
 
	/*
	 * Read one line from other side
	 */
	int netLineGet (PNetLine, const char **);
 
	/*
	 * Send plain text to other side
	 */
	int netPut (PNetLine, const char *);
 
#ifdef __cplusplus
}
#endif
 
#endif