\section{test003block.c File Reference}
\label{test003block_8c}\index{test003block.c@{test003block.c}}
This program tests the low-level block transfer and authentication functions. 


{\tt \#include $<$stdio.h$>$}\par
{\tt \#include $<$arpa/inet.h$>$}\par
{\tt \#include $<$sys/types.h$>$}\par
{\tt \#include $<$signal.h$>$}\par
{\tt \#include \char`\"{}libcomm.h\char`\"{}}\par
{\tt \#include $<$unistd.h$>$}\par
\subsection*{Defines}
\begin{CompactItemize}
\item 
\#define {\bf PORT}\ 1235
\begin{CompactList}\small\item\em Port on which the server is listening and the client trys to connect.\item\end{CompactList}\item 
\#define {\bf bufsize}\ 8192
\begin{CompactList}\small\item\em How much random bytes should be transfered?\item\end{CompactList}\item 
\#define {\bf threadid}\ 1234
\begin{CompactList}\small\item\em The ID which identifies the thread of the {\bf block\_\-call}() {\rm (p.\,\pageref{libcomm_8c_a6})} function.\item\end{CompactList}\end{CompactItemize}
\subsection*{Functions}
\begin{CompactItemize}
\item 
{\bf main} (int argc, char $\ast$argv[$\,$])
\begin{CompactList}\small\item\em test0001sockts: see test0001sockts.c.\item\end{CompactList}\item 
{\bf client\_\-test\_\-program} (char $\ast$server, int port, int auth)
\begin{CompactList}\small\item\em test0001sockts: see test0001sockts.c, Client Test Programm.\item\end{CompactList}\item 
{\bf block\_\-call\_\-do\_\-test} (int fd, int id, unsigned int type, char $\ast$buf, unsigned int size, int term)
\begin{CompactList}\small\item\em testfunction which ist called from {\bf block\_\-call}() {\rm (p.\,\pageref{libcomm_8c_a6})} if a message/datablock has received.\item\end{CompactList}\item 
{\bf block\_\-call\_\-term\_\-test} (int fd, int id)
\begin{CompactList}\small\item\em testfunction which ist called from {\bf block\_\-call}() {\rm (p.\,\pageref{libcomm_8c_a6})} if a the connection terminates.\item\end{CompactList}\item 
{\bf socket\_\-accept\_\-do\_\-test} (int fd, int id, char $\ast$pip, struct sockaddr\_\-in their\_\-addr, int term)
\begin{CompactList}\small\item\em testfunction which ist called from {\bf socket\_\-accept}() {\rm (p.\,\pageref{libcomm_8c_a1})} if someone has connected.\item\end{CompactList}\item 
{\bf server\_\-test\_\-program} (int port, int mode)
\begin{CompactList}\small\item\em test0001sockts: see test0001sockts.c, Server Test Programm.\item\end{CompactList}\end{CompactItemize}


\subsection{Detailed Description}
This program tests the low-level block transfer and authentication functions.





\subsection{Define Documentation}
\index{test003block.c@{test003block.c}!bufsize@{bufsize}}
\index{bufsize@{bufsize}!test003block.c@{test003block.c}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}\#define bufsize\ 8192}\label{test003block_8c_a1}


How much random bytes should be transfered?

\index{test003block.c@{test003block.c}!PORT@{PORT}}
\index{PORT@{PORT}!test003block.c@{test003block.c}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}\#define PORT\ 1235}\label{test003block_8c_a0}


Port on which the server is listening and the client trys to connect.

\index{test003block.c@{test003block.c}!threadid@{threadid}}
\index{threadid@{threadid}!test003block.c@{test003block.c}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}\#define threadid\ 1234}\label{test003block_8c_a2}


The ID which identifies the thread of the {\bf block\_\-call}() {\rm (p.\,\pageref{libcomm_8c_a6})} function.

This value can be coosen arbitrary and is passwd to all called functions. 

\subsection{Function Documentation}
\index{test003block.c@{test003block.c}!block_call_do_test@{block\_\-call\_\-do\_\-test}}
\index{block_call_do_test@{block\_\-call\_\-do\_\-test}!test003block.c@{test003block.c}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}block\_\-call\_\-do\_\-test (int {\em fd}, int {\em id}, unsigned int {\em type}, char $\ast$ {\em buf}, unsigned int {\em size}, int {\em term})}\label{test003block_8c_a5}


testfunction which ist called from {\bf block\_\-call}() {\rm (p.\,\pageref{libcomm_8c_a6})} if a message/datablock has received.

\index{test003block.c@{test003block.c}!block_call_term_test@{block\_\-call\_\-term\_\-test}}
\index{block_call_term_test@{block\_\-call\_\-term\_\-test}!test003block.c@{test003block.c}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}block\_\-call\_\-term\_\-test (int {\em fd}, int {\em id})}\label{test003block_8c_a6}


testfunction which ist called from {\bf block\_\-call}() {\rm (p.\,\pageref{libcomm_8c_a6})} if a the connection terminates.

\index{test003block.c@{test003block.c}!client_test_program@{client\_\-test\_\-program}}
\index{client_test_program@{client\_\-test\_\-program}!test003block.c@{test003block.c}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}client\_\-test\_\-program (char $\ast$ {\em server}, int {\em port}, int {\em auth})}\label{test003block_8c_a4}


test0001sockts: see test0001sockts.c, Client Test Programm.

The client test program generates a block of n$\ast$(bufsize) random bytes, sents theses bytes to the server, receive a block from server, invert it and compare it with generated block.

BUGS: Receives only one block. If not all data ready and function resv() do noct block, data get lost. Test fails.\begin{Desc}
\item[Parameters: ]\par
\begin{description}
\item[{\em 
server}](char $\ast$) contains the server name\item[{\em 
port}](int) specifies the port on the server\item[{\em 
auth}](int) 0: normale test; 1: do authentification before run test. \end{description}
\end{Desc}
\index{test003block.c@{test003block.c}!main@{main}}
\index{main@{main}!test003block.c@{test003block.c}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}main (int {\em argc}, char $\ast$ {\em argv}[$\,$])}\label{test003block_8c_a3}


test0001sockts: see test0001sockts.c.

\index{test003block.c@{test003block.c}!server_test_program@{server\_\-test\_\-program}}
\index{server_test_program@{server\_\-test\_\-program}!test003block.c@{test003block.c}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}server\_\-test\_\-program (int {\em port}, int {\em mode})}\label{test003block_8c_a8}


test0001sockts: see test0001sockts.c, Server Test Programm.

The server test program binds a port and waits for connections. If someone connects it reads n$\ast$(bufsize) bytes, invert all bits of these bytes and send all back.

BUGS: Receives only one block. If not all data ready and function resv() do noct block, data get lost. Test fails.\begin{Desc}
\item[Parameters: ]\par
\begin{description}
\item[{\em 
port}](int) specify the port to bind.\item[{\em 
mode}](int) select the mode of receiving a message/datablock: 0: blocked mode, use {\bf block\_\-receive}() {\rm (p.\,\pageref{libcomm_8c_a9})}; 1: poll mode, poll with {\bf block\_\-receive\_\-poll}() {\rm (p.\,\pageref{libcomm_8c_a8})}; 2: call function {\bf block\_\-call\_\-do\_\-test}() {\rm (p.\,\pageref{test003block_8c_a5})} if a block is received, use {\bf block\_\-call}() {\rm (p.\,\pageref{libcomm_8c_a6})}; 3: call {\bf socket\_\-accept\_\-do\_\-test}() {\rm (p.\,\pageref{test003block_8c_a7})} if someone has connected. This function calls {\bf block\_\-call}() {\rm (p.\,\pageref{libcomm_8c_a6})} which does the same like in 2, use {\bf socket\_\-accept}() {\rm (p.\,\pageref{libcomm_8c_a1})}; 4: testing authenication by using {\bf socket\_\-md5auth}() {\rm (p.\,\pageref{libcomm_8c_a14})}. After this do the same as in 0. \end{description}
\end{Desc}
\index{test003block.c@{test003block.c}!socket_accept_do_test@{socket\_\-accept\_\-do\_\-test}}
\index{socket_accept_do_test@{socket\_\-accept\_\-do\_\-test}!test003block.c@{test003block.c}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}socket\_\-accept\_\-do\_\-test (int {\em fd}, int {\em id}, char $\ast$ {\em pip}, struct sockaddr\_\-in {\em their\_\-addr}, int {\em term})}\label{test003block_8c_a7}


testfunction which ist called from {\bf socket\_\-accept}() {\rm (p.\,\pageref{libcomm_8c_a1})} if someone has connected.

