Tiny programs (C, C++, C#, ...)
File detail
Source code
/*
* file: netio.h - TCP layer
* project: BSD Sockets (IPK)
* By Kamil Dudka, xdudka00
* mailto: xdudka00@gmail.com
*/
#ifndef NETIO_H
#define NETIO_H
#ifdef __cplusplus
extern "C" {
#endif
// TCP Layer ADT
typedef int TSocket;
typedef int (*PAcceptProc) (TSocket);
typedef struct NetLine TNetLine, *PNetLine;
/*
* Start concurent server
* procAddr - procedure called for incoming connection
* return only if an error occur
*/
int netListen (unsigned portNumber, unsigned listenQueue, PAcceptProc procAddr);
/*
* 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, char **);
/*
* Send plain text to other side
*/
int netPut (PNetLine, const char *);
#ifdef __cplusplus
}
#endif
#endif