source: trunk/instant_messenger/socket/BKP_20071105/BKP_20071026/BKP_20071019/BKP_20071018/BKP_20071009/BKP_20071008/BKP/server.h @ 151

Revision 151, 2.0 KB checked in by niltonneto, 16 years ago (diff)

Commit da nova versão do módulo, usando agente em C.
Vide Página do módulo do Trac:
http://www.expressolivre.org/dev/wiki/messenger

A versão anterior encontra-se na subpasta bkp (32/64).

Line 
1#include <fcntl.h>
2
3#include <linux/tcp.h>
4
5#include <netdb.h>
6#include <netinet/in.h>
7#include <netinet/tcp.h>
8
9#include <openssl/ssl.h>
10#include <openssl/err.h>
11#include <openssl/crypto.h>
12#include <openssl/x509.h>
13#include <openssl/pem.h>
14#include <openssl/bio.h>
15
16#include <pthread.h>
17
18#include <signal.h>
19#include <sys/types.h>
20#include <sys/socket.h>
21#include <string.h>
22#include <stdio.h>
23#include <stdlib.h>
24
25#include <unistd.h>
26
27/* define max clients per child */
28#ifndef __CLIENTS__
29   #define __CLIENTS__ 100
30#endif
31
32/* define max clients waiting in the queue for connect */
33#ifndef __QUEUE_SIZE__
34        #define __QUEUE_SIZE__ 10
35#endif
36
37/* __SOCKET_ERROR__ must be -1, don't change this */
38#ifndef __SOCKET_ERROR__
39        #define __SOCKET_ERROR__ -1
40#endif
41
42/* open port when this server is activated */
43#ifndef __DEFAULT_OPEN_PORT__
44        #define __DEFAULT_OPEN_PORT__ 8888
45#endif
46
47/* ip of jabber service */
48#ifndef __DEFAULT_JABBER_PORT__
49        #define __DEFAULT_JABBER_PORT__ 5222
50#endif
51
52/* port to connect on jabber service */
53#ifndef __DEFAULT_JABBER_IP__
54        #define __DEFAULT_JABBER_IP__ "10.15.20.202"
55#endif
56
57/* the jabber's documentation recommends read the packages of socket with size of 4096 (2^12) KB */
58#ifndef __BUFFER_SIZE__
59        #define __BUFFER_SIZE__ 4096
60#endif
61
62#define MESSAGE                 "This is the message I'm sending back and forth"
63
64/* Make these what you want for certificate & key files */
65#define CERT_FILE "mycert.pem"
66#define KEY_FILE  "mycert.pem"
67
68/*Cipher list to be used*/
69#define CIPHER_LIST "RC4-MD5"
70
71/*Trusted CAs location*/
72#define CA_FILE CERT_FILE
73#define CA_DIR NULL
74
75/*Password for the key file*/
76#define KEY_PASSWD ""
77
78#ifndef __CLEAR_SCREEN__
79        #define __CLEAR_SCREEN__ "clear"
80#endif
81
82/* 0 -> false; 1 -> true */
83#ifndef __DEBUG__
84        #define __DEBUG__ 0
85#endif
86
87struct client
88{
89        int fd;
90        struct sockaddr_in sockaddr;
91        pthread_t thread;
92        SSL * myssl;
93        time_t last;
94        struct client * next;
95};
96
97void * handler(void *);
98
99void usage (void)
100{
101        puts("usage: ./server <PORT>\n\n");
102        exit (-1);
103}
Note: See TracBrowser for help on using the repository browser.