Kannel: Open Source WAP and SMS gateway  svn-r5335
test_conn.c File Reference
#include <string.h>
#include <unistd.h>
#include <signal.h>
#include "gwlib/gwlib.h"

Go to the source code of this file.

Functions

int main (int argc, char **argv)
 

Function Documentation

◆ main()

int main ( int  argc,
char **  argv 
)

Definition at line 70 of file test_conn.c.

References conn_destroy(), conn_open_tcp(), debug(), get_and_set_debugs(), gwlib_init(), gwlib_shutdown(), gwthread_sleep(), host, octstr_create, octstr_destroy(), octstr_get_cstr, panic, and port.

71 {
72  Connection *conn;
73  Octstr *host = NULL;
74  int port, i;
75 
76  gwlib_init();
77 
78  get_and_set_debugs(argc, argv, NULL);
79 
80  if (argc < 3)
81  panic(0, "Syntax: %s <host> <port>\n", argv[0]);
82 
83  host = octstr_create(argv[1]);
84  port = atoi(argv[2]);
85  i = 50;
86 
87  debug("",0,"Connecting to host '%s', port %d, looping %i times.",
89 
90  for (i = 0; i <= 50; i++) {
91  conn = conn_open_tcp(host, port, NULL);
92  if (conn == NULL) {
93  panic(0, "Couldn't connect.");
94  }
95  debug("",0,"%d: connected.", i);
96  gwthread_sleep(0.2);
97  debug("",0,"%d: closing.", i);
98  conn_destroy(conn);
99  }
100 
102  gwlib_shutdown();
103  return 0;
104 }
Definition: http.c:2014
Connection * conn_open_tcp(Octstr *host, int port, Octstr *our_host)
Definition: conn.c:496
static Octstr * host
Definition: fakesmsc.c:122
#define octstr_get_cstr(ostr)
Definition: octstr.h:233
static int port
Definition: fakesmsc.c:121
void conn_destroy(Connection *conn)
Definition: conn.c:627
void octstr_destroy(Octstr *ostr)
Definition: octstr.c:324
#define octstr_create(cstr)
Definition: octstr.h:125
void gwthread_sleep(double seconds)
Definition: octstr.c:118
void debug(const char *place, int err, const char *fmt,...)
Definition: log.c:726
#define panic
Definition: log.h:87
void gwlib_shutdown(void)
Definition: gwlib.c:94
void gwlib_init(void)
Definition: gwlib.c:78
int get_and_set_debugs(int argc, char **argv, int(*find_own)(int index, int argc, char **argv))
Definition: utils.c:626
See file LICENSE for details about the license agreement for using, modifying, copying or deriving work from this software.