Index of /uczelnia/Network-Programming/3.select


../
multi_client.c                                 ..-...-.... ..:..:..                   10192
multi_serwer.c                                 ..-...-.... ..:..:..                   19970
README                                         ..-...-.... ..:..:..                   2507
session_with_multiclient                       ..-...-.... ..:..:..                   2639
session_with_multiserver                       ..-...-.... ..:..:..                   1487


COMPILATION:
 Linux:
gcc multi_serwer.c -o gmserwer -Wall -ansi                 [-lwrap -DHAVE_LIBWRAP]
gcc multi_client.c -o gmclient -Wall -ansi
 Solaris:
gcc multi_serwer.c -o gmserwer -Wall -ansi  -lnsl -lsocket [-lwrap -DHAVE_LIBWRAP]
gcc multi_client.c -o gmclient -Wall -ansi  -lnsl -lsocket

CLIENT
======
 + Examples how to use client are in session_with_multiclient
 + In session_with_multiserver there is everything what server
   was doing in the same time...


SERVER
======

FEATURES:
 + easy development
 + using /etc/hosts.(allow|deny), 
   [compile with flags: -DHAVE_LIBWRAP -lwrap]
 + ability to add diferent functions on the same port
   for different protocols [ipv4, ipv6]
 + compiles clearly with -Wall and -ansi ;)
   [but not with -pedantic because of the way I initialize stuff in 'ski'
    array :)]


Everything is in one file, because I tend to write programs splitted
into files, and I wanted to know if I'll be able to do this this way ;)

Program can be stopped with Ctrl-C [if this sends SIGINT on your machine :)]


DEVELOPING MULTI_SERWER PROGRAM:

first take a look at function dodawanie [addition], mnozenie
[multiplication], leetspeech

IN 'RECEIVER' FUNCTION YOU MUSTN'T MODIFY BUFFERS FROM ski ARRAY.
YOU HAVE TO DECLARE YOUR OWN TEMPORARY BUFFERS INSIDE FUNCTIONS
[I EVEN THOUGHT ABOUT DECLARING ONE SHARED BUFFER]
IF YOU WANT TO SENT BACK ANYTHING TO CLIENT YOU HAVE TO PUT IT
ON A QUEUE USING add_to_queue FUNCTION.
[TAKE A LOOK AT FUCNTIONS: mnozenie, dodawanie, leetspeech]

entries in g_sokecik structure gave the following form:
   { {.port = 10000 }, PF_INET,  SOCK_STREAM, dodawanie,  "add"   }

(*) first element is in the case of unix family:
    {.path = "path where you want to create unix socket"},
    in the case of inet or inet6 family, number of port on which
    server will be running
(*) next element is family [one of]: PF_(UNIX|INET|INET6)
(*) next is protocol type [currently SOCK_STREAM or SOCK_DGRAM]
(*) fourth element is name of the function [returning int i and taking int]
(*) last element is service name, that can be latter used in entries in
    /etc/hosts.(allow|deny)

Because I wanted to make it possible to connect to server
using Window's [tm] telnet, and because how I implemented odbieramy()
function, communication is based on strings ended with '\n'

[It is important, when writing client based on unix family,
 [I'm writing this because, I myself have forgoten to include '\n'
  in strings send to unix family socket :D]]