source: trunk/instant_messenger/bkp/socket/BKP_20071105/BKP_20071026/BKP_20071019/BKP_20071018/BKP_20071009/BKP_20071008/BKP/BKP/server_27092007.h @ 216

Revision 216, 1.9 KB checked in by niltonneto, 16 years ago (diff)

Correções do módulo instant_messenger.
Ver WiKi? em: http://www.expressolivre.org/dev/wiki/messenger

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