/examples/trigger.c (cf898fdb3e114ee7b1b3f9485ca875c173731c99) (1624 bytes) (mode 100644) (type blob)
#define _GNU_SOURCE
#include <errno.h>
#include <string.h>
#include <strings.h>
#include <stdlib.h>
#include <unistd.h>
#include <sys/poll.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <stdio.h>
#include <fcntl.h>
#include <netinet/in.h>
#include <sys/time.h>
#include <sys/ioctl.h>
#include <time.h>
#include <arpa/inet.h>
#include <stdarg.h>
#include <Conn.h>
/* Global variables */
static unsigned short debug = 1;
static void trigger(struct Conn *C)
{
printf("Trigger is running on %llu!\n", Conn_getid(C));
}
int main(void)
{
char *stat;
int ret;
struct Conn *C;
Conn_debug(NULL, debug);
ret = Conn_init(0);
if (ret == -1) {
printf("%s", Conn_strerror());
return 1;
}
printf("Trying to register IPv4 socket...\n");
C = Conn_alloc();
if (!C) {
printf("Cannot alloc socket [%s].\n", Conn_strerror());
} else {
Conn_set_socket_domain(C, PF_INET);
Conn_set_socket_type(C, SOCK_STREAM);
Conn_set_socket_bind_addr(C, "127.0.0.1");
Conn_set_socket_bind_port(C, 60000);
ret = Conn_commit(C);
if (ret != 0) {
printf("Cannot bind on ipv4 socket [%s].\n",
Conn_strerror());
}
}
/* Install connection specific trigger */
Conn_set_cb(C, CONN_CB_TRIGGER, trigger);
/* Force a timeout for connect (in seconds) */
Conn_set(C, CONN_PARA_TRIGGER, 3);
while (1) {
ret = Conn_poll(1000);
if (ret == -1) {
printf("Error in poll [%s]!\n",
Conn_strerror());
break;
}
if (ret == 0) {
printf("Finish work!\n");
break;
}
if (debug >= 9) {
stat = Conn_status(0);
printf("%s\n", stat);
free(stat);
}
}
Conn_shutdown();
return 0;
}
Mode |
Type |
Size |
Ref |
File |
100644 |
blob |
70 |
9964a59b5d89f394cc4250ed6d6ce67a5f0cd196 |
.gitignore |
100644 |
blob |
1945 |
fecf0e7a7e8580485101a179685aedc7e00affbb |
Changelog.pre109 |
100644 |
blob |
30249 |
ceacb607291f1b9d26131f56d979d3e04c22e9b5 |
Conn.c |
100644 |
blob |
1470 |
afedf88dd9c3b275e9c7d83d6572c2fcce60e50b |
Conn.h |
100644 |
blob |
726 |
64b1bad93a84f87c3e93fc24ac5341db691ea578 |
Conn.spec.in |
100644 |
blob |
66 |
68138d781ca754b15e14c687da91ee261b2c41f3 |
Conn_config.h.in |
100644 |
blob |
27985 |
34e68f838096277281cdb368ad1c3ecc5cd04bc1 |
Conn_engine_core.c |
100644 |
blob |
9091 |
94b3b4cf54424d7a6e01f8a441c1c048b79cd595 |
Conn_engine_core.h |
100644 |
blob |
3687 |
8ae607cf9e14a6f9f1d9f17f468294660986e845 |
Conn_engine_epoll.c |
100644 |
blob |
601 |
b7631d5fc5487b502f02679b0d679661f87b4da9 |
Conn_engine_epoll.h |
100644 |
blob |
2677 |
e885b694fc0f55200ee50936966a2e40744ebf9b |
Conn_engine_poll.c |
100644 |
blob |
588 |
b518b20ac383c00b72e96a77a882c6b7ee953f6f |
Conn_engine_poll.h |
100644 |
blob |
30 |
d987fa5df957830331139935d517009e2911b0cf |
INSTALL |
100644 |
blob |
25275 |
92b8903ff3fea7f49ef5c041b67a087bca21c5ec |
LICENSE |
100644 |
blob |
1311 |
3c820df3b36b4bc844c52bc8c7e86f7843b67bb6 |
Makefile.in |
100644 |
blob |
192 |
5b11bdfb23857d8588845465aef993b320596b44 |
README |
100644 |
blob |
2101 |
c1d87e72d02403b09acd37ccc74da2ae122f7dcd |
TODO |
100755 |
blob |
23 |
d33bb6c4ecdce1390ce1db3c79ea3b93e22ea755 |
configure |
040000 |
tree |
- |
d4c9c4a69c5cfa2a84316967185f1661b6817779 |
docs |
100755 |
blob |
10344 |
8acd6afdceefbb056b57e9d09a9943857800df8e |
duilder |
100644 |
blob |
276 |
4163f35b9322fbbf5e9cade154d251b39878c43f |
duilder.conf |
040000 |
tree |
- |
c1f7bd01e5be435012e5a1eabdb1430467572ddd |
examples |
040000 |
tree |
- |
751693d0803f700dd060788cc9383aa24b472267 |
tests |
Hints:
Before first commit, do not forget to setup your git environment:
git config --global user.name "your_name_here"
git config --global user.email "your@email_here"
Clone this repository using HTTP(S):
git clone https://rocketgit.com/user/catalinux/Conn
Clone this repository using ssh (do not forget to upload a key first):
git clone ssh://rocketgit@ssh.rocketgit.com/user/catalinux/Conn
Clone this repository using git:
git clone git://git.rocketgit.com/user/catalinux/Conn
You are allowed to anonymously push to this repository.
This means that your pushed commits will automatically be transformed into a
merge request:
... clone the repository ...
... make some changes and some commits ...
git push origin main