SHOW:
|
|
- or go back to the newest paste.
1 | - | #include <sys/types.h> |
1 | + | int Making_Socket( int * list_sd, struct hosten ** server, struct sockaddr_in * addr, char * adres, int on, long port) |
2 | - | #include <stdio.h> |
2 | + | |
3 | - | #include <stdlib.h> |
3 | + | int rc=0; |
4 | - | #include <sys/socket.h> |
4 | + | *list_sd = socket(AF_INET, SOCK_STREAM, 0); |
5 | - | #include <netinet/in.h> |
5 | + | if (*list_sd < 0) |
6 | - | #include <string.h> |
6 | + | |
7 | - | #include <arpa/inet.h> |
7 | + | |
8 | - | #include <fcntl.h> |
8 | + | |
9 | - | #include <unistd.h> |
9 | + | |
10 | - | #include <ctype.h> |
10 | + | |
11 | - | #include <sys/ioctl.h> |
11 | + | *server = gethostbyname(adres); |
12 | - | #include <sys/poll.h> |
12 | + | if(*server == NULL) |
13 | - | #include <sys/time.h> |
13 | + | |
14 | - | #include <errno.h> |
14 | + | |
15 | - | #include <netdb.h> |
15 | + | |
16 | - | #include <time.h> |
16 | + | |
17 | - | #include <sys/timerfd.h> |
17 | + | |
18 | rc = setsockopt(*list_sd, SOL_SOCKET, SO_REUSEADDR, (char *)&on, sizeof(on)); | |
19 | - | void Raporting(char * buf, int raport, int count); |
19 | + | |
20 | - | char* CheckingParameters(int argc, char*argv[], int* t, char* adres, long* port); |
20 | + | error("setsockopt()", *list_sd); |
21 | - | void nano(float od_czas); |
21 | + | |
22 | - | void error(char* fun, int fd); |
22 | + | rc = ioctl(*list_sd, FIONBIO, (char *)&on); |
23 | - | int CheckingRcv(int rc, int * clCon); |
23 | + | |
24 | - | char makeBuffer(int * data_size, char cc, char buf[], char* send_buf ); |
24 | + | error("ioctl()", *list_sd); |
25 | - | void GettingTime( int raport); |
25 | + | |
26 | - | char Add_to_Buffer(int * data_size, char cc, char buf[], int* il_mat); |
26 | + | |
27 | - | int Take_from_Buffer(int * data_size, char buf[], char * send_buf); |
27 | + | |
28 | - | void Raport3(int raport, int data_size, int *il_mat, int *il_wydan, int nfds); |
28 | + | memset(&addr, 0, sizeof(*addr)); |
29 | - | void Raport2( int * il_blocks, int raport, char * adrIp); |
29 | + | |
30 | addr.sin_family = AF_INET; | |
31 | bcopy((char*)(*server)->h_addr, (char*)addr.sin_addr.s_addr, (*server)->h_length); | |
32 | - | // BUFOR |
32 | + | |
33 | ||
34 | rc = bind(*list_sd, (struct sockaddr *)addr, sizeof(*addr)); | |
35 | - | #define BUFSIZE 200 // rozmiar bufora |
35 | + | |
36 | - | #define GIVESIZE 3 // rozmiar bloku do wypelniania |
36 | + | error("bind()", *list_sd); |
37 | - | #define SENDSIZE 180 // rozmiar pobieranych danych |
37 | + | |
38 | rc = listen(*list_sd, 128); | |
39 | - | char buf[BUFSIZE]; |
39 | + | |
40 | - | char *pIn, *pOut, *pEnd; |
40 | + | error("listen()", *list_sd); |
41 | - | char full; |
41 | + | } |
42 | ||
43 | - | void buf_init() |
43 | + | Making_Socket(&list_sd, &server, &addr, adres, on, port); |