1
/* $Id: main.c 3553 2011-05-05 06:14:19Z nanang $ */
3
* Copyright (C) 2008-2011 Teluu Inc. (http://www.teluu.com)
4
* Copyright (C) 2003-2008 Benny Prijono <benny@prijono.org>
6
* This program is free software; you can redistribute it and/or modify
7
* it under the terms of the GNU General Public License as published by
8
* the Free Software Foundation; either version 2 of the License, or
9
* (at your option) any later version.
11
* This program is distributed in the hope that it will be useful,
12
* but WITHOUT ANY WARRANTY; without even the implied warranty of
13
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
* GNU General Public License for more details.
16
* You should have received a copy of the GNU General Public License
17
* along with this program; if not, write to the Free Software
18
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
22
#include <pj/string.h>
27
extern int param_echo_sock_type;
28
extern const char *param_echo_server;
29
extern int param_echo_port;
32
//#if defined(PJ_WIN32) && PJ_WIN32!=0
35
static void boost(void)
37
SetPriorityClass(GetCurrentProcess(), REALTIME_PRIORITY_CLASS);
43
#if defined(PJ_SUNOS) && PJ_SUNOS!=0
45
static void init_signals()
49
memset(&act, 0, sizeof(act));
50
act.sa_handler = SIG_IGN;
52
sigaction(SIGALRM, &act, NULL);
56
#define init_signals()
59
int main(int argc, char *argv[])
68
char *arg = argv[--argc];
70
if (*arg=='-' && *(arg+1)=='i') {
73
} else if (*arg=='-' && *(arg+1)=='p') {
74
pj_str_t port = pj_str(argv[--argc]);
76
param_echo_port = pj_strtoul(&port);
78
} else if (*arg=='-' && *(arg+1)=='s') {
79
param_echo_server = argv[--argc];
81
} else if (*arg=='-' && *(arg+1)=='t') {
82
pj_str_t type = pj_str(argv[--argc]);
84
if (pj_stricmp2(&type, "tcp")==0)
85
param_echo_sock_type = pj_SOCK_STREAM();
86
else if (pj_stricmp2(&type, "udp")==0)
87
param_echo_sock_type = pj_SOCK_DGRAM();
89
PJ_LOG(3,("", "error: unknown socket type %s", type.ptr));
100
puts("Press <ENTER> to exit");
101
if (!fgets(s, sizeof(s), stdin))